如何运行一个golang程序为守护进程
发布网友
发布时间:2022-04-22 02:22
我来回答
共1个回答
热心网友
时间:2024-08-14 21:25
安装daemonize
安装git环境
1
yum install git -y
获取daemonize
1
git clone git://github.com/<a href="https://www.baidu.com/s?wd=bmc&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLP1cYrywWnjm1uAc3rjDz0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPWcdnW6sn1nkn1f4n1fdrj6Y" target="_blank" class="baidu-highlight">bmc</a>/daemonize.git
安装daemonize
1
2
3
cd daemonize
./configure
make && make install
查看是否安装
1
daemonize -v
通过daemonize执行golang守护进程
需要打包golang程序为可执行文件(go build),并通过daemonize来执行它来实现守护进程,如:
1
daemonize -p /var/run/myapp.pid -l /var/lock/subsys/myapp -u nobody /path/to/myapp