ubuntu22.04开机自启动Eureka服务

ubuntu22.04开机自启动Eureka服务

1、创建启动脚本eurekaService.sh

shell 复制代码
#我们把启动脚本放在/usr/software目录下
cd /usr/software
vim eurekaService.sh

eurekaService.sh内容为

shell 复制代码
#!/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、赋予可执行权限

shell 复制代码
chmod 777 eurekaService.sh

3、新建要启动的Eureka服务文件

shell 复制代码
#新建要启动的服务文件
vim /etc/systemd/system/eureka.service

eureka.service内容为

shell 复制代码
[Unit]
Description=this is eurekaService 
After=network.target
[Service]
Type=forking
ExecStart=/usr/software/eurekaService.sh  #指定上面创建的脚步文件路径
[Install]
WantedBy=multi-user.target  #多用户

4、启动Eureka服务

shell 复制代码
#让系统获取到你刚自定义的service文件并设置开机启动
systemctl daemon-reload
systemctl start eureka.service

systemctl enable eureka.service

#查看日志
systemctl status eureka.service
相关推荐
阿里云云原生14 小时前
Agent 观测与优化三城巡演丨第二站深圳精彩回顾 & PPT 下载
云原生
Henry-SAP18 小时前
AI产业迎来标准化与商业化双突破
人工智能·云原生·sap·erp
报错小能手1 天前
Kubernetes入门实战课 3
云原生·容器·kubernetes
2601_962219011 天前
版本平滑升级架构:万象生鲜系统 V4.3.3 迭代无停机更新技术拆解
微服务·云原生·架构
阿里云云原生1 天前
深入解析 STAROps 瑶池 Agent:如何实现从应用告警到数据库命令级的全栈 RCA?
云原生
阿里云云原生1 天前
告别手工配置:利用 Migration Skill 实现 Nginx Ingress 注解的智能分析与自动转换
云原生
2601_962218471 天前
万象生鲜系统冷链物联网接入技术实现生鲜企业温控管理数字化
大数据·运维·微服务·云原生·架构
阿里云云原生1 天前
Event-Driven AI 架构解析:从 Confluent Intelligence 三大支柱到阿里云实践
云原生
阿里云云原生1 天前
从手工回测到全自动化:AgentLoop 在 Agent Engineering 中的落地与实践总结
云原生·agent
报错小能手1 天前
Kubernetes入门实战课 1
云原生·容器·kubernetes