Search code examples
ansiblemesos

Starting Apache mesos in daemon mode


Does anyone know where the init scripts for mesos 1.3.0 are? (I've built mesos from source on ubuntu 16.0)

I'm starting mesos like the following currently, via ansible:

/opt/mesos/build/bin/mesos-master.sh --ip=`hostname -i` --work_dir=/var/lib/mesos

However, the moment Ansible disconnects from the terminal, mesos process dies. So it seems this way of starting mesos is not compatible with a remote, automated installation.

I've tried preceding the command with nohup, and backgrounding it as well as in this script (to no avail):

#!/bin/bash
# Start the mesos slave 
# Start Mesos master (ensure work directory exists and has proper  permissions).
 nohup /opt/mesos/build/bin/mesos-agent.sh --master=`cat    /tmp/master.ip`:5050 --work_dir=/var/lib/mesos &```

It only seems to work when I run it by hand, logged on to a terminal, and starting it via ansible doesn't result in the process staying running.


Solution

  • Mesos does not come with daemon init scripts. You need to prepare them by youself.

    You can take a look at mesosphere/mesos-deb-packaging

    For example systemd script could look like this:

    [Unit]
    Description=Mesos Master
    After=network.target
    Wants=network.target
    
    [Service]
    ExecStart=/usr/bin/mesos-init-wrapper master
    Restart=always
    RestartSec=20
    LimitNOFILE=16384
    
    [Install]
    WantedBy=multi-user.target