I have a python script and that I have to run as a service/background process, I have tried python-daemon but it gives me errors is there any good way to run it as a service so that the script can be run in the background to accept messages and process files?
-
Can you provide the errors you are receiving?Tim– Tim2018-01-30 04:12:56 +00:00Commented Jan 30, 2018 at 4:12
-
os.umask(022) # Don't allow others to writechris1234– chris12342018-01-30 04:16:49 +00:00Commented Jan 30, 2018 at 4:16
-
This is what i have tried "pypi.python.org/pypi/python-daemon"chris1234– chris12342018-01-30 04:17:13 +00:00Commented Jan 30, 2018 at 4:17
-
Again please provide a code example that you have tried and the errors you are receiving?Tim– Tim2018-01-30 07:22:42 +00:00Commented Jan 30, 2018 at 7:22
Add a comment
|
1 Answer
I have made a sytemctl service file in /lib/systemed/system The file content is
[Unit]
Description=RPC SERVER
After=network.target
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/
Type=simple
ExecStart=/usr/bin/ python3 /home/ubuntu/rpc.py
[Install]
WantedBy=multi-user.target
/home/ubuntu/rpc.py is my python script path and i saved the file as rpcservertest.service so i can start the service using sudo systemctl start rpcservertest.service to stop sudo systemctl stop rpcservertest.service and to get status sudo systemctl status rpcservertest.service