How to automatically start Mango in a systemd based Linux OS
-
Some Linux distributions as CentOS or RedHat are migrating from systemV init type to the newest systemd.
If this is your case, you will need to do as follow to make Mango runs with every system startup:
Create a mango.service file:
touch /etc/systemd/system/mango.service
chmod 664 /etc/systemd/system/mango.serviceEdit the new file so it contains the following:
[Unit]
Description=Mango Daemon Service
After=network.target
After=network-online.target[Service]
Type=forking
ExecStart=/opt/mango/bin/ma.sh start
ExecStop=/opt/mango/bin/ma.sh stop
ExecReload=/opt/mango/bin/ma.sh restart
PIDFile=/opt/mango/bin/ma.pid[Install]
WantedBy=multi-user.targetNOTE: You will need to point the mango directory path to whatever your MA_HOME is.
Reload systemd configuration files:
systemctl daemon-reloadAdd mango to systemd, so it runs on every system startup:
systemctl enable mango.serviceThat's it. Now you can manage the Mango service with the following shell commands:
systemctl [start|stop|reload|status] mango
Good luck!
Editted by Phil: original PIDFile entry --> PIDFile=/opt/ambilogger/bin/ma.pid, edited from ambiguity in: https://forum.infiniteautomation.com/topic/3179/centos-7-systemd-startup-failing
-
I'll add an Upstart script for Ubuntu, I have been using this with Ubuntu 14.04. This one lets you run mango as a non-root user. Restart doesn't work too well as ma-stop.sh doesn't stop Mango immediately.
From Ubuntu 15.04 onwards systemd is used instead of Upstart so dont use this script.
# mango - Mango Automation # # Mango Automation is a Java web app for monitoring and logging data sources description "Mango Automation" start on (local-filesystems and net-device-up IFACE=eth0) stop on runlevel [!2345] #respawn #respawn limit 10 5 umask 002 setuid mango setgid mango env MA_HOME=/opt/mango export MA_HOME console log script . "$MA_HOME"/bin/ma-init.sh export JPDA EXECJAVA JAVAOPTS SYSOUT SYSERR exec "$MA_HOME"/bin/ma-start.sh end script pre-stop script "$MA_HOME"/bin/ma-stop.sh end script
-
@Jared-Wiltshire
Hi Jared I am wondering if you would generate a systemd script for our Ubuntu 16.04 LTS and show it here as the one provided above complains of an error when I tried this script in our system?
I Appreciate any help on this. -
@aoliver This worked for me on a RPi3 thanks!
-
@aoliver said in How to automatically start Mango in a systemd based Linux OS:
PIDFile=/opt/ambilogger/bin/ma.pid
although, this PIDFile=/opt/ambilogger/bin/ma.pid should be /opt/mango/bin ;-)