I just got everything set and done with my python flask project and I would like to make a service out of it.
In order to get started, I've made a bash file which is supposed to start the server and can be located in /home/pi
#!/bin/bash cd /home/pi/Desktop/secure-pi-tensorflow python3 /home/pi/Desktop/secure-pi-tensorflow/run.py
My service file looks like this:
[Unit] After=multi-user.target [Service] Type=idle ExecStart=/home/pi/securepi.sh [Install] WantedBy=multi-user.target
The problem that I am facing is that I am able to power up the server with the bash file, but it doesn't start as a service, this error pops up:
pi@securepi:~ $ systemctl status securepi.service Warning: The unit file, source configuration file or drop-ins of securepi.service changed on disk. Run 'systemctl daemon-reload' to reload units. ● securepi.service Loaded: loaded (/lib/systemd/system/securepi.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2019-10-28 15:42:39 GMT; 8min ago Process: 1325 ExecStart=/usr/bin/python3 /home/pi/Desktop/secure-pi-tensorflow/run.py (code=exited, status=1/FAILURE) Main PID: 1325 (code=exited, status=1/FAILURE) Oct 28 15:42:38 securepi systemd: Started securepi.service. Oct 28 15:42:39 securepi python3: Traceback (most recent call last): Oct 28 15:42:39 securepi python3: File "/home/pi/Desktop/secure-pi-tensorflow/run.py", line 12, in <module> Oct 28 15:42:39 securepi python3: from securepi import app Oct 28 15:42:39 securepi python3: File "/home/pi/Desktop/secure-pi-tensorflow/securepi/__init__.py", line 4, in <module> Oct 28 15:42:39 securepi python3: from flask_jsglue import JSGlue Oct 28 15:42:39 securepi python3: ModuleNotFoundError: No module named 'flask_jsglue' Oct 28 15:42:39 securepi systemd: securepi.service: Main process exited, code=exited, status=1/FAILURE Oct 28 15:42:39 securepi systemd: securepi.service: Failed with result 'exit-code'.
Does anybody have any idea what's going on with that error? Everything runs just fine when powered by the bash file but always fails when the service tries
Also I would like to mention that the flask_jsglue in installed for both python2.7 and 3
pi@securepi:~ $ python3 Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import flask_jsglue + Stopped python3 pi@securepi:~ $ python Python 2.7.16 (default, Apr 6 2019, 01:42:57) [GCC 8.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import flask_jsglue