CentOS 7 systemd Startup Failing
-
I followed the directions for adding Mango to a CentOS 7 systemd service startup. Unfortunately when I use "systemctl start mango" it fails with a "Job for mango.service failed because a timeout was exceeded. See "systemctl status mango.service" and "journalctl -xe" for details."
I added a "TimeoutSec=250" to the Service section of the mango.service file. But it still times out. I think this is because the startup script is not exiting properly so systemd keeps waiting for the service to start. If I run the "ma.sh start" script from a command line, it doesn't return to a command prompt until I hit "return".
The last line in the ma.log file is: "INFO 2018-01-01T10:17:22,046 (org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler:362) - Mapped URL path [/sqlConsole.shtm] onto handler of type [class com.serotonin.m2m2.web.mvc.UrlHandlerController]"
Any ideas?
Re: How to automatically start Mango in a systemd based Linux OS
-
Hi thutchis,
That last line is typical of a successful boot. Are you sure that is a result of trying to execute the service?
There is nothing in the ma.sh script to pause until a key is pressed. I think you are maybe not seeing the new shell line it printed because there is all the Mango output competing with it for your eyes, then you're hitting return to get another still.
Are you passing anything as input in your service? In our service file on the MangoES we control the standard streams as such:
/path/to/Mango/bin/ma.sh start >/dev/null 2>&1 </dev/null
-
Thanks for the reply Phil,
Yes, that is the result of "sysctl start mango"
You were right, if I use "ma.sh>/dev/null 2>&1</dev/null start" as root/sudo on the command line I do get a new command line prompt immediately. So something else isn't letting systemd know the script (and Mango startup) was successful.
Here is my /etc/systemd/system/mango.service file:
[Unit]
Description=Mango Daemon Service
After=network.target
After=network-online.target[Service]
Type=forking
ExecStart=/opt/mango/bin/ma.sh start>/dev/null 2>&1 </dev/null
ExecStop=/opt/mango/bin/ma.sh stop>/dev/null 2>&1 </dev/null
ExecReload=/opt/mango/bin/ma.sh restart>/dev/null 2>&1 </dev/null
PIDFile=/opt/ambilogger/bin/ma.pid
TimeoutSec=250[Install]
WantedBy=multi-user.target -
Maybe you could direct your stdout and stderr to a file to see what's going on.
ExecStart=/opt/mango/bin/ma.sh start>/opt/mango/logs/service.log 2>&1 </dev/null
You'll just want to set this back once it's working or that file could consume the whole disk if the log output ever explodes.
-
@phildunlap
Thanks again Phil,Problem solved. I blindly followed the instructions at https://forum.infiniteautomation.com/topic/2246/how-to-automatically-start-mango-in-a-systemd-based-linux-os and didn't read the entire thread. In the [Service] section of the mango.service file it says to put "PIDFile=/opt/ambilogger/bin/ma.pid". I don't know what "ambilogger" is and there isn't a directory "/opt/ambilogger" so the startup script would fail. The last entry in the thread corrected that to "PIDFile=/opt/mango/bin/ma.pid". I fixed the line in the "mango.service" file and now it works. Sheesh.
-
Ah! Thanks for sharing what the cause and solution were. I went back and edited that post so that Dan's suggestion (this issue) was /opt/mango/bin/ma.pid in the original post
Glad you got it working!