0

This is script content, located in /etc/init.d/myserviced:

#!/lib/init/init-d-script

DAEMON="/usr/local/bin/myprogram.py"
NAME="myserviced" 
DESC="The description of my service"

When I start the service (either by calling it directly or by calling sudo service myserviced start), I can see program myprogram.py run, but it did not return to command prompt.

I guess there must be something that I misunderstood, so what is it?

The system is Debian, running on a Raspberry Pi.

jiandingzhe
  • 1,881
  • 15
  • 35

1 Answers1

0

After more works, I finally solved this issue. There are 2 major reasons:

  • init-d-script actually calls start-stop-daemon, who don't work well with scripts specified via --exec option. When killing scripts, you should only specify --name option. However, as init-d-script always fill --exec option, it cannot be used with script daemons. I have to write the sysv script by myself.

  • start-stop-daemon won't magically daemonize the thing you provide. So the executable provided to start-stop-daemon should be daemonized itself, but not a regular program.

jiandingzhe
  • 1,881
  • 15
  • 35