{{format('0')}} {{format('427')}} {{format('2921')}}

Centos8 创建/启动服务 报错 Control process exited, code=exited status=203 [ 技术杂谈 ]

九叶的小窝 文章 正文

As Long As You Love Me.
分享

九叶

{{nature("2021-07-02 08:48:05")}}更新

1. 问题

1.1 描述

部署spring cloud项目开机自启脚本的时候遇到了报错

5月 31 10:27:20 localhost.noob systemd[1]: Starting springcloud - resource recovery service...
5月 31 10:27:20 localhost.noob systemd[1]: recovery.service: Control process exited, code=exited status=203
5月 31 10:27:20 localhost.noob systemd[1]: recovery.service: Failed with result 'exit-code'.
5月 31 10:27:20 localhost.noob systemd[1]: Failed to start springcloud - resource recovery service.

2. 解决方案

2.1 新建 启动/停止/重启服务的shell文件

2.1.1 启动 recovery-start
#!/bin/bash
javaOptions="-Dfile.encoding=utf-8 -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m"

nohup java $javaOptions -jar /recovery/ruoyi-gateway.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-auth.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-system.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-gen.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-file.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-recovery.jar >/dev/null 2>&1 & 
2.1.2 停止 recovery-stop
#!/bin/bash

ps -ef | grep ruoyi | grep -v grep | cut -c 10-16 | xargs kill -9
2.1.3 重启 recovery-restart
#!/bin/bash
javaOptions="-Dfile.encoding=utf-8 -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m"

ps -ef | grep ruoyi | grep -v grep | cut -c 10-16 | xargs kill -9

nohup java $javaOptions -jar /recovery/ruoyi-gateway.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-auth.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-system.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-gen.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-file.jar >/dev/null 2>&1 & 
nohup java $javaOptions -jar /recovery/ruoyi-modules-recovery.jar >/dev/null 2>&1 & 

2.2 创建 recovery.service 服务启动项

2.2.1 新建 recovery.service 服务文件

systemd有系统和用户区分

系统(/usr/lib/systemd/system/)

用户(/etc/lib/systemd/user/)

一般系统管理员手工创建的单元文件建议存放在/etc/systemd/system/目录下面。

vim /lib/systemd/system/recovery.service
[Unit]
Description=springcloud - resource recovery service
Documentation=https://qwq.ro
After=network.target
[Service]
Type=forking
ExecStart=/bin/bash /recovery/bin/recovery-start
ExecReload=/bin/bash /recovery/bin/recovery-restart
ExecStop=/bin/bash /recovery/bin/recovery-stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target

3. 测试

systemctl daemon-reload # 先进行文件生效配置 systemctl enable recovery.service # 设置为开机启动 systemctl start recovery.service # 启动nacos服务 systemctl stop recovery.service # 停止nacos服务


![image.png](https://old.qwq.ro/usr/uploads/2021/05/2310004218.png)
评论 0
0
{{userInfo.data?.nickname}}
{{userInfo.data?.email}}
TOP 2
Minecraft | [1.12.2] 核电工艺模拟器 1.2.25 —— 汉化版

{{nature('2021-12-07 15:29:00')}} {{format('2671')}}人已阅读

TOP 3
SSM搭建Spring单元测试环境

{{nature('2021-01-31 20:01:00')}} {{format('1172')}}人已阅读

TOP 4
dispatcher-servlet.xml文件配置模板

{{nature('2020-12-11 21:17:00')}} {{format('1085')}}人已阅读

TOP 5
Windows平台Nacos启动报错无法创建Bean实例

{{nature('2021-04-22 15:16:00')}} {{format('1058')}}人已阅读

目录

标签云

CentOS

一言

# {{hitokoto.data.from || '来自'}} #
{{hitokoto.data.hitokoto || '内容'}}
作者:{{hitokoto.data.from_who || '作者'}}
自定义UI
配色方案

侧边栏