Makefile
但在服务器上,如何自动在收到上传后自动停止服务,解压二进制包,替换旧二进制文件,再启动。这是个一直困扰我的问题。
Debiansystemdservice
service
想了很多办法,但都不如意:
GolanggitgitHook
理想方案shell
Debianinotify-tools
一个监控脚本:
1
2
3
4
5
6
7
8
9
#!/bin/bash
filename=$1
inotifywait -mq --format '%f,%e' -e close_write $filename | while read file
do
case $file in messager.tgz,CLOSE_WRITE,CLOSE) service messager restart;;
esac
case $file in crmd.tgz,CLOSE_WRITE,CLOSE) service crmd restart ;;
esac
done
为这个监测脚本编写守护服务:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cat /usr/lib/systemd/system/watchdog.service
[Unit]
Description=Watch dog server
[Service]
Type=simple
Restart=always
User=root
Group=root
RestartSec=3
ExecStart=/usr/local/bin/watchdog /usr/local/bin
[Install]
WantedBy=multi-user.target
启动它
`systemctl enable watchdog`
`service watchdog start`
make install