Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rc.d - no support for python scripts



Hi!

Thanks. I hadn't realized the shebang line was used by rc.subr.

The attached version of the startup script seems to work fine.
 Thomas

On Sun, Aug 23, 2020 at 12:06:44AM +1000, Luke Mewburn wrote:
> Hi Thomas,
> 
> Have you tried replacing your /bin/sh startup script with
> a python script (using the same interpreter path
> that your app uses) that does the same thing?
> 
> cheers,
> Luke.
> 
> On 20-08-17 09:55, Thomas Klausner wrote:
>   | Hi Leo!
>   | 
>   | On Mon, Aug 17, 2020 at 09:45:08AM +0200, Leonardo Taccari wrote:
>   | > > I wanted to run a python service using an rc.d script. It knows to write a pid file, but that is not good enough for our rc.d system. It complains:
>   | > >
>   | > > # /etc/rc.d/syncserver stop                                                                                                                  
>   | > > syncserver not running? (check /home/wiz/Projects/syncserver/syncserver.pid).
>   | > >
>   | > > I think this happens because the executable is not called “syncserver” but is started using a python2.7 binary. So I tried setting
>   | > >
>   | > > command_interpreter="/home/wiz/Projects/syncserver/local/bin/python2.7"
>   | > >
>   | > > but then I got
>   | > >
>   | > > /etc/rc.d/syncserver: WARNING: $command_interpreter /home/wiz/Projects/syncserver/local/bin/python2.7 != /bin/sh
>   | > >
>   | > > Is there a way to get python programs running nicely with rc.d and pid support (i.e. “status” and “stop” support)?
>   | > > [...]
>   | > 
>   | > Was `command' adjusted too to the path of the script?
>   | > Can you please share the possible problematic rc.d script?
>   | > 
>   | > pkgsrc/chat/miniircd/files/miniircd.sh is a possible example (but it
>   | > doesn't use any pidfile).
>   | 
>   | I think the issue is with the pidfile support. Starting the service works fine.
>   | 
>   | Attached are the rc.d script and the file from /usr/local that is the
>   | actual start script.
>   |  Thomas
#!/bin/sh
#
# $NetBSD$
#
# PROVIDE: syncserver
# REQUIRE: DAEMON

. /etc/rc.subr

name="syncserver"
rcvar=${name}
command="/home/wiz/Projects/syncserver/local/bin/gunicorn"
command_interpreter="/home/wiz/Projects/syncserver/local/bin/python2.7"
required_files="/home/wiz/Projects/syncserver/syncserver.ini"
pidfile="/home/wiz/Projects/syncserver/syncserver.pid"
syncserver_chdir="/home/wiz/Projects/syncserver/"
syncserver_flags="--paste /home/wiz/Projects/syncserver/syncserver.ini --access-logfile /var/log/syncserver.log  --log-syslog --pid /home/wiz/Projects/syncserver/syncserver.pid"

load_rc_config $name
run_rc_command "$1"


Home | Main Index | Thread Index | Old Index