tonypowa / sensor-data-monitoring-grafana

0 stars 2 forks source link

cannot not get app.py to run as a service #2

Open radiorusso opened 4 weeks ago

radiorusso commented 4 weeks ago

I have been trying to get your sensor data monitoring program to run but have run into a road block. The app script wont run as a service. The path is correct and the script has be set to be executable. I get an 203 error here is what happens when I check the service pi@raspberrypi:~/sensor-data-monitoring-grafana $ pi@raspberrypi:~/sensor-data-monitoring-grafana $ sudo systemctl daemon-reload pi@raspberrypi:~/sensor-data-monitoring-grafana $ sudo systemctl enable sensor-flask.service --now pi@raspberrypi:~/sensor-data-monitoring-grafana $ systemctl status sensor-flask.service ● sensor-flask.service - A service that will keep my python app running in the background Loaded: loaded (/etc/systemd/system/sensor-flask.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2024-10-25 13:11:13 EDT; 17s ago Process: 18272 ExecStart=/usr/lib/python3 /usr/local/bin/app.py (code=exited, status=203/EXEC) Main PID: 18272 (code=exited, status=203/EXEC)

Oct 25 13:11:13 raspberrypi systemd[1]: sensor-flask.service: Service RestartSec=100ms expired, scheduling restart. Oct 25 13:11:13 raspberrypi systemd[1]: sensor-flask.service: Scheduled restart job, restart counter is at 5. Oct 25 13:11:13 raspberrypi systemd[1]: Stopped A service that will keep my python app running in the background. Oct 25 13:11:13 raspberrypi systemd[1]: sensor-flask.service: Start request repeated too quickly. Oct 25 13:11:13 raspberrypi systemd[1]: sensor-flask.service: Failed with result 'exit-code'. Oct 25 13:11:13 raspberrypi systemd[1]: Failed to start A service that will keep my python app running in the background. pi@raspberrypi:~/sensor-data-monitoring-grafana $ 203 error

Also what does Change is the ExecStart flag Where do I go from here ?? Thanks in advance

Russ

radiorusso commented 2 weeks ago

Any help on this issue ? It has been driving me nuts !! russ Rshummel1@cox.net

tonypowa commented 1 week ago

Hi @radiorusso,

Thank you for reporting this issue.

It looks like an issue related to the path, or permissions.

Make sure that the python exec path is correct

which python3

If the path differs (e.g., /usr/bin/python3), update ExecStart accordingly.

Ensure that app.py is executable:

sudo chmod +x /usr/local/bin/app.py

After making changes, reload systemd and restart the service:

sudo systemctl daemon-reload
sudo systemctl restart sensor-flask.service

Hope it helps!

tonypowa commented 2 days ago

FYI

I have just released a Dockerized version of this project (see https://github.com/tonypowa/sensor-data-monitoring-grafana/blob/main/README.md). With Docker there is no need to create a service. You might want to try if that solves the issue.

If you still want to access the files of the old version, checkout the old version: