Question

how to start multiple daemons , they are "not" instances they are different daemons. i have used the following script but upstart hangs on start after stopping the daemons and restarting them.

#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

and here is the init file for a daemon.

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

manual 'stop' works fine but 'start' hangs. please advise.

here is the daemon source code.

#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; 
}
Was it helpful?

Solution

after many trials and errors finally solved it myself. removing "task" keyword from the master script "akorp.conf" file solves the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top