systemctl启动方式
自定义jar包启动配置
[root@vm10-37-0-159 system]# cat /lib/systemd/system/rocketmq-console.service [Unit] Description=rocketmq-console server Wants=network-online.target After=network.target [Service] Type=forking WorkingDirectory=/root/scribe/ ExecStart=/bin/bash rocketmq-console.sh start ExecStop=/bin/bash rocketmq-console.sh stop ExecReload=/bin/bash rocketmq-console.sh restart Restart=on-failure [Install] WantedBy=multi-user.target
自定义启动脚本
[root@vm10-37-0-159 scribe]# cat /root/scribe/rocketmq-console.sh #!/bin/bash # source /etc/profile jarName="rocketmq-console-ng-1.0.0.jar" workDir="/mq/rocketmq-externals-rocketmq-console-1.0.0/rocketmq-console/target" start(){ cd ${workDir} && java -jar ${jarName} >uams.log 2>&1 & } stop(){ ps -ef | grep -qP "(?<=-jar)\s+${jarName}" && kill $(ps -ef | grep -P "(?<=-jar)\s+${jarName}" | awk '{print $2}') } case $1 in start) start ;; stop) stop ;; restart) stop start ;; esac
查看
systemctl enable rocketmq-console.service systemctl start rocketmq-console.service systemctl status rocketmq-console.service