在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任意进入一个日志文件查看是否有内容,有内容代表启动成功

相关推荐
爱吃橘子橙子柚子4 小时前
3CPU性能排查总结(超详细)【Linux性能优化】
运维·cpu
Johny_Zhao5 小时前
OpenClaw中级到高级教程
linux·人工智能·信息安全·kubernetes·云计算·yum源·系统运维·openclaw
Sheffield1 天前
Docker的跨主机服务与其对应的优缺点
linux·网络协议·docker
Sheffield1 天前
Alpine是什么,为什么是Docker首选?
linux·docker·容器
舒一笑2 天前
程序员效率神器:一文掌握 tmux(服务器开发必备工具)
运维·后端·程序员
Johny_Zhao2 天前
centos7安装部署openclaw
linux·人工智能·信息安全·云计算·yum源·系统运维·openclaw
haibindev2 天前
在 Windows+WSL2 上部署 OpenClaw AI员工的实践与踩坑
linux·wsl2·openclaw
NineData2 天前
数据库管理工具NineData,一年进化成为数万+开发者的首选数据库工具?
运维·数据结构·数据库
梦想很大很大3 天前
拒绝“盲猜式”调优:在 Go Gin 项目中落地 OpenTelemetry 链路追踪
运维·后端·go