I have created my own service by:
- copying my binary to
- Create a daemon copying the skeleton:
Modify the skeleton bash script top:
PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Runs my Service" NAME=mcp DAEMON=/usr/bin/$NAME DAEMON_ARGS="-d f -c /etc/mcp" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME
Other than this the skeleton is exactly the same.
Then I create the daemon:
sudo update-rc.d -f mcp remove sudo update-rc.d mcp defaults 97 03
When I run the program manually:
mcp -d f -c /etc/mcp, it works, but it never returns since its a service that is meant to always run. This is normal.
But now when I start it as a service:
sudo service mcp start, I see the same behavior. I.e. as soon as I enter the start service command, the program runs, but now my terminal is stuck waiting for the program.
I thought if you run something as a service then it should be running in the background?
Also I can't stop this service unless I open a second terminal. I kind of want it so that when I start the service it starts somewhere in the background and then you return to the command line. Am I doing something wrong here?