在linux中怎样同时运行三个微服务保证退出时不会终止

前言

1.maven中打jar包

使用插件打包,必须在pom.xml中添加插件,否则不能在linux中编译运行

复制代码
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.1.1.RELEASE</version>
                <configuration>
                    <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warName>${project.artifactId}</warName>
                </configuration>
            </plugin>
        </plugins>
        <finalName>${project.artifactId}</finalName>
    </build>

2.将在maven中打包好的文件存放在linux的指定目录中

3.使用命令启动jar包,同时创建记录日志的文件(在此使用三个微服务为例),只需更换为自己的jar包名称

shop-gateway.jar, shop-order-server.jar, shop-product-server.jar

nohup java -jar shop-gateway.jar > gateway.log 2>&1 & nohup java -jar shop-order-server.jar > order.log 2>&1 & nohup java -jar shop-product-server.jar > product.log 2>&1

4.先使用命'netstat -ntlp'查看是否服务占用了端口,若占用了端口说明启动成功

5.使用vim任意进入一个日志文件查看是否有内容,有内容代表启动成功

相关推荐
IT成长日记2 小时前
【Docker基础】Docker数据持久化与卷(Volume)介绍
运维·docker·容器·数据持久化·volume·
小马爱打代码3 小时前
微服务外联Feign调用:第三方API调用的负载均衡与容灾实战
微服务·架构·负载均衡
物联网老王4 小时前
Ubuntu Linux Cursor 安装与使用一
linux·运维·ubuntu
艾伦_耶格宇6 小时前
【ACP】阿里云云计算高级运维工程师--ACP
运维·阿里云·云计算
一位摩羯座DBA6 小时前
Redhat&Centos挂载镜像
linux·运维·centos
学习3人组6 小时前
CentOS配置网络
linux·网络·centos
weixin_307779137 小时前
Hive集群之间迁移的Linux Shell脚本
大数据·linux·hive·bash·迁移学习
漫步企鹅7 小时前
【蓝牙】Linux Qt4查看已经配对的蓝牙信息
linux·qt·蓝牙·配对
cui_win7 小时前
【网络】Linux 内核优化实战 - net.core.flow_limit_table_len
linux·运维·网络
梦在深巷、7 小时前
MySQL/MariaDB数据库主从复制之基于二进制日志的方式
linux·数据库·mysql·mariadb