Hi Guys,
i am trying to run a mono application as a service.
the host is a VPS by OVH.net running CentOS 7 x64.
i have installed mono-complete and created a new user which will be used to run the service.
i created a new service called: "fivem.service" in the /usr/lib/systemd/system directory with the following contents:
[Unit]
Description=FiveM Server
After=network.target
[Service]
User=fivem
Group=fivem
Type=forking
ExecStart=/home/fivem/run.sh start
ExecStop=/home/fivem/run.sh stop
PIDFile=/tmp/fivem.lock
[Install]
WantedBy=multi-user.target
as you can see, it refers to /home/fivem/run.sh start to run the script that will run mono.
that script looks like this:
#!/bin/bash
PROGRAM_NAME="fivem"
LOCK_FILE="/tmp/"${PROGRAM_NAME}".lock"
usage()
{
echo "$0 (start|stop)"
}
stop()
{
if [ -e ${LOCK_FILE} ]
then
_pid=$(cat ${LOCK_FILE})
kill $_pid
rt=$?
if [ "$rt" == "0" ]
then
echo "Demon stop"
else
echo "Error stop demon"
fi
else
echo "Demon is not running"
fi
}
start()
{
mono-service -l:${LOCK_FILE} /home/fivem/CitizenMP.Server.exe
}
case $1 in
"start")
start
;;
"stop")
stop
;;
*)
usage
;;
esac
exit
Now the problem is: when i run that script as user fivem in a ssh console like this: sh /home/fivem/run.sh start the CitizenMP.Server.exe server starts and everything works perfectly! But when i start it with the fivem.service like: service fivem start i can see a mono process consuming 100% CPU and will eventually kill itself after 10 seconds or so.
i really hope you guys can help me out, i have been busy with this for the last couple of days and i cant find a way to fix this problem
Problem with runninga mono application as a service
-
- Posts: 1
- Joined: 2017/05/11 22:34:08
Re: Problem with runninga mono application as a service
Interesting, how do you know that it's obsessing on CPU. Memory is so much slower than CPU, it probably isn't (being a bit pedantic, ignore me).i can see a mono process consuming 100% CPU
Very good netizen, knows something is wrong and does the only choice left to it!eventually kill itself after 10 seconds or so.
Why the shell script? Very SYSV not systemd like at all. Systemd has many differenet ways of launching programs depending on the behaviour of the program (and they are detailed on Lennart Poettering's blog - http://0pointer.net/blog/). Go native, it'll make your life easier....
Re: Problem with runninga mono application as a service
I installed Mono 5.0.0 by mistake (latest release) and I'm not sure how to completely removed all associated files so I can install Mono 4.8.1. Anyone have a suggestion on that?
Thanks,
Perry
Thanks,
Perry
Re: Problem with runninga mono application as a service
Seems you've "hijacked" a post. You'd be better off posting in your own thread.
How did you install mono (i.e.: RPM/tarball/compilation)?
How did you install mono (i.e.: RPM/tarball/compilation)?