如何启动多个守护进程,它们是“非”实例,它们是不同的守护进程。我已经使用了以下脚本,但是在停止守护进程并重新启动后,upstart会在启动时挂起。
#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
这是守护进程的init文件。
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;
}
答案 0 :(得分:0)