如何启动多个守护进程,它们是“非”实例,它们是不同的守护进程。我使用了以下脚本,但新贵在停止守护程序并重新启动它们后挂起。
#ubuntu upstart script for antkorp services
description "Antkorp colloboration and communication platform"
author "www.antkorp.in"
task
start on runlevel [2345]
stop on runlevel [016]
pre-start script
logger -t "antkorp:" "antkorp platform booting...";
end script
post-start script
logger -t "antkorp:" "antkorp platform started successfully.";
end script
pre-stop script
logger -t "antkorp:" "antkorp platform stopping..";
end script
post-stop script
logger -t "antkorp:" "antkorp platform stopped successfully.";
end script
这是守护进程的初始化文件。
description "antkorp gw daemon"
start on starting akorp
stop on stopping akorp
expect fork
respawn
pre-start script
logger -t "gw:" "antkorp gw daemon about to start.";
end script
exec /home/rk/gw
post-start script
logger -t "gw:" "antkorp gw daemon started successfully.";
end script
pre-stop script
logger -t "gw:" "antkorp gw daemon stopping ...";
end script
post-stop script
logger -t "gw:" "antkorp gw daemon stopped.";
end script
手动“停止”工作正常,但“开始”挂起。请指教。
这是守护进程源代码。
#include<stdio.h>
#include<unistd.h>
#include<signal.h>
#include<stdlib.h>
void
sigterm_handler(int signo)
{
exit(1);
return;
}
int
main(int ac, char **av)
{
signal(SIGTERM, sigterm_handler);
daemon(0,0);
while(1) sleep(1);
return 0;
}