I'm facing an issue with a python file that I'd like to start as a service. I named my service ocrserver and the script I want to start is in /home/administrator/ocr/ocrserver/init.py with some parameters added like --address --port etc... After reading the documentation from the FreeBSD site
I wrote the following script:
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: ocrserver
# REQUIRE: NETWORK
# KEYWORD: shutdown
# add the following line to /etc/rc.conf to enable the ocrserver:
# ocrserver_enable="YES"
. /etc/rc.subr
name="ocrserver"
rcvar="ocrserver_enable"
# default values
: ${ocrserver_enable="NO"}
base_path="/home/administrator/ocr/ocrserver"
address="localhost"
http_port=8080
pyproxy_port=10800
log_level="debug"
pidfile="${base_path}/ocrserver.pid"
command="/usr/sbin/daemon"
# -p : daemon handler pidfile
# -f : redirect stdout and stderr to /dev/null
# -c : change working dir to root
command_args="-p ${pidfile} -f -c /home/administrator/ocr/ocrserver/__init__.py \
--address ${address} --http-port ${http_port} --log-level ${log_level} \
--pyproxy-port ${pyproxy_port}"
procname="/home/administrator/ocr/ocrserver/__init__.py"
command_interpreter="/usr/local/bin/python3.3"
load_rc_config $name
run_rc_command "$1"
Then I added one line setting up the corresponding rcvar to YES in the /etc/rc.conf file. and I launched it:
sudo service ocrserver start where I get the message "Starting ocrserver". and after entering a sudo service ocrserver status, I can see that the service is not running. I also ran a pgrep -l python3.3 command to see if any python3 process was running but no result
I precise that I did a chmod 755 on the file to make it readable and executable by all the users.
Has anyone some experience with this kind of thing?
Thanks for your answers.