Hi all
I've been working on creating an RPM for CentOS. I have several internal
versions using the master branch [0.14.0] but I have not been able to
daemonize it correctly, as in /etc/init.d/functions::daemonize. I am able
to start it but not to kill it with, not sure if I am using the correct
sigterm, thoughts around this will be appreciated?

Example of the init.d file for mesos-master available on the following link:
https://github.com/Guavus/incubator-mesos/blob/support/guavus-master/src/deploy/mesos-masterd.sh.in

I think it will be nice if there was a *daemonize* flag that we could set
to the *mesos-master* and *mesos-slave such that *they would redirect
stdout an err to dev null and fork (redis does that), not sure if I can do
it wuth libprocess.

e.g. https://github.com/antirez/redis/blob/unstable/src/redis.c
```c

void daemonize(void) {
    int fd;

    if (fork() != 0) exit(0); /* parent exits */
    setsid(); /* create a new session */

    /* Every output goes to /dev/null. If Redis is daemonized but
     * the 'logfile' is set to 'stdout' in the configuration file
     * it will not log at all. */
    if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
        dup2(fd, STDIN_FILENO);
        dup2(fd, STDOUT_FILENO);
        dup2(fd, STDERR_FILENO);
        if (fd > STDERR_FILENO) close(fd);
    }
}

```

Again, thoughts appreciated.
Best
Bernardo.

Reply via email to