ubuntu22.04開機(jī)自啟動(dòng)Eureka服務(wù)
1、創(chuàng)建啟動(dòng)腳本eurekaService.sh
#我們把啟動(dòng)腳本放在/usr/software目錄下
cd /usr/software
vim eurekaService.sh
eurekaService.sh內(nèi)容為文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-699364.html
#!/bin/sh
# this is a eurekaService shell to startup at the mechian power on.
echo "eurekaServer-0.0.1-SNAPSHOT.jar service start loading..."
nohup java -jar /usr/software/eurekaServer-0.0.1-SNAPSHOT.jar > /usr/software/log.txt 2>&1 &
echo "eurekaService loads successful"
2、賦予可執(zhí)行權(quán)限
chmod 777 eurekaService.sh
3、新建要啟動(dòng)的Eureka服務(wù)文件
#新建要啟動(dòng)的服務(wù)文件
vim /etc/systemd/system/eureka.service
eureka.service內(nèi)容為文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-699364.html
[Unit]
Description=this is eurekaService
After=network.target
[Service]
Type=forking
ExecStart=/usr/software/eurekaService.sh #指定上面創(chuàng)建的腳步文件路徑
[Install]
WantedBy=multi-user.target #多用戶
4、啟動(dòng)Eureka服務(wù)
#讓系統(tǒng)獲取到你剛自定義的service文件并設(shè)置開機(jī)啟動(dòng)
systemctl daemon-reload
systemctl start eureka.service
systemctl enable eureka.service
#查看日志
systemctl status eureka.service
到了這里,關(guān)于ubuntu22.04開機(jī)自啟動(dòng)Eureka服務(wù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!