如果单纯使用shell脚本来管理启动,停止,也不是不行,但是稍微繁琐点,并且没办法批量管理各个服务的运行情况
我最近尝试注册服务的方式来管理java服务
在/lib/systemd/system 中添加服务
例如添加文件:xxx.service
[Unit]
Description=****
After=network.target
#StandardOutput=/root/****/api/****/log.out
[Service]
Type=simple
ExecStart=/usr/bin/java -jar /root/****/api/****/****.jar>>/root/****/api/****/log.out 2>&1
#ExecStop=/bin/sh /root/****/api/****/stop.sh
#StandardOutput=null
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target
但是比较坑爹的是,这种方式好像没办法输出日志到指定位置
不知道大家平时是怎么部署java项目的?
Jenkins+docker一把刷