Python script as rc service on FreeBSD operating system
2
votes
1
answer
1231
views
I have a Python script that I would like to run in a FreeNAS jail. It works without the service daemon, but I would like to start it as a service.
I have created the following service script **
/etc/rc.d/attendance
**
#!/bin/sh
# PROVIDE: attendance
# REQUIRE: DAEMON
# KEYWORD: shutdown
. /etc/rc.subr
name=attendance
rcvar=attendance_enable
load_rc_config $name
: ${attendance_enable="NO"}
pidfile="/var/run/${name}.pid"
command="/root/Zkteco/app.py"
command_interpreter=/usr/local/bin/python
run_rc_command "$1"
I have also added **attendance_enable="YES"
** under /etc/rc.conf
.
When I run **service attendance start
** I receive
Starting attendance
limits: /root/Zkteco/app.py: No such file or directory
/etc/rc.d/attendance: WARNING: failed to start attendance
Even though the directory exists, I tried moving it from /etc/rc.d/attendance
to /usr/local/etc/rc.d/attendance
and it seems to work, but it never goes as a background process either and I have to Ctrl+C to stop it.
Any recommendation?
The script is a web application using FastAPI and Uvicorn, does it have anything to do with it?
How can I see the logs of the service error trying to start.
**Thing I’ve tried**
I created a binary with pyinstaller --onefile
from the script. And
changed
#!/bin/sh
.
.
.
command="/usr/local/bin/app"
run_rc_command "$1
This change made the service start but again, it never goes to background.
Asked by Ukhu
(21 rep)
May 8, 2023, 10:12 PM
Last activity: Oct 24, 2024, 05:50 AM
Last activity: Oct 24, 2024, 05:50 AM