Quantcast
Viewing latest article 4
Browse Latest Browse All 6

Python program not being started by rc.d in FreeBSD 7.1

Image may be NSFW.
Clik here to view.
Question

I have a python program which I wrote and would like to run on startup in FreeBSD 7.1.

For my current installation, the script lives at
/home/devuser/project/trunk/src/proj. At the beginning of my main in proj I have added (for testing)

os.system("echo 'proj STARTED' >> /tmp/projlog")

In /usr/local/etc/rc.d/ I have ‘proj’ which contains:

#!/bin/sh
# PROVIDE: proj
# REQUIRE: DAEMON LOGIN
# KEYWORD: shutdown
. "/etc/rc.subr"$location="/home/devuser/project/trunk/src"name="proj"
rcvar=`set_rcvar`
command="$location/$name"
command_args="$1"
command_interpreter="python"load_rc_config $name
echo "trying to run proj" >> /tmp/rclog
run_rc_command "$1"

In my rc.conf:

rc_debug="YES"
proj_enable="YES"

If I run /usr/local/etc/rc.d/proj <start|stop|status> as root everything works as expected – proj runs, trying to run proj appears in /tmp/rclog, and proj STARTED appears in /tmp/projlog.

On system startup, I get trying to run proj in /tmp/rclog, but nothing in /tmp/projlog – python isn’t being started.

Why is the rc script running but failing to actually invoke Python, and not giving me any feedback?

Image may be NSFW.
Clik here to view.
Answer

I’m guessing /usr/local/bin (or wherever the python binary resides in FreeBSD) doesn’t exist in $PATH when running init scripts.

Try changing command_interpreter="python" to command_interpreter="/usr/local/bin/python".

Also, does the your file contain a shebang (with a correct path) and is executable?


Viewing latest article 4
Browse Latest Browse All 6

Trending Articles