Post by dertown on Apr 7, 2022 5:11:28 GMT -8
If anyone was interested I used the following to make the SG3.py and index.py into services.
As root
add the following lines to the file
----
add the following lines to the file
----
---
Reload the daemons on the raspberry pi
Start the services
Then check the status of the services
You will see this status. I dont have a garden cam so I get a message but the important line is the active line
Loaded: loaded (/lib/systemd/system/sg3.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-04-07 07:45:16 EDT; 1h 25min ago
Main PID: 21466 (python3)
Tasks: 17 (limit: 4915)
CGroup: /system.slice/sg3.service
└─21466 /usr/bin/python3 /home/pi/SDL_Pi_SmartGarden3/SG3.py
You will see this result
SG3 Service
As root
cd /lib/systemd/system
sudo nano sg3.service
add the following lines to the file
----
[Unit]
Description=SG3
After=multi-user.target
[Service]
Type=simple
WorkingDirectory=/home/pi/SDL_Pi_SmartGarden3
ExecStart=/usr/bin/python3 /home/pi/SDL_Pi_SmartGarden3/SG3.py
Restart=on-abort
[Install]
WantedBy=multi-user.target
sudo nano sg3dash.service
add the following lines to the file
----
[Unit]
Description=SG3
After=multi-user.target
[Service]
Type=simple
WorkingDirectory=/home/pi/SDL_Pi_SmartGarden3/dash_app/
ExecStart=/usr/bin/python3 /home/pi/SDL_Pi_SmartGarden3/dash_app/index.py
Restart=on-abort
[Install]
WantedBy=multi-user.target
---
Reload the daemons on the raspberry pi
sudo systemctl daemon-reload
Start the services
sudo systemctl start sg3.service
sudo systemctl start sg3dash.service
Then check the status of the services
sudo systemctl status sg3.service
You will see this status. I dont have a garden cam so I get a message but the important line is the active line
sg3.service - SG3
Loaded: loaded (/lib/systemd/system/sg3.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-04-07 07:45:16 EDT; 1h 25min ago
Main PID: 21466 (python3)
Tasks: 17 (limit: 4915)
CGroup: /system.slice/sg3.service
└─21466 /usr/bin/python3 /home/pi/SDL_Pi_SmartGarden3/SG3.py
Apr 07 07:45:16 smartgarden systemd[1]: Started SG3.
Apr 07 07:45:18 smartgarden python3[21466]: mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
Apr 07 07:45:18 smartgarden python3[21466]: mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
sg3.service - SG3Loaded: loaded (/lib/systemd/system/sg3.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-04-07 07:45:16 EDT; 1h 25min ago
Main PID: 21466 (python3)
Tasks: 17 (limit: 4915)
CGroup: /system.slice/sg3.service
└─21466 /usr/bin/python3 /home/pi/SDL_Pi_SmartGarden3/SG3.py
sudo systemctl status sg3dash.service
You will see this result
sg3dash.service - SG3
Loaded: loaded (/lib/systemd/system/sg3dash.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-04-06 23:16:24 EDT; 9h ago
Main PID: 5222 (python3)
Tasks: 6 (limit: 4915)
CGroup: /system.slice/sg3dash.service
└─5222 /usr/bin/python3 /home/pi/SDL_Pi_SmartGarden3/dash_app/index.py
Apr 07 07:46:56 smartgarden python3[5222]: end= 2022-04-07 07:46:30
Apr 07 07:46:56 smartgarden python3[5222]: --------------------->>>>>>>>>>>>>>>>new page
Apr 07 07:46:56 smartgarden python3[5222]: begin= 2022-04-07 07:46:42
Apr 07 07:46:56 smartgarden python3[5222]: pathname= /log_page
Apr 07 07:46:56 smartgarden python3[5222]: previousPathname= /camera_page
Apr 07 07:46:56 smartgarden python3[5222]: i= ['url.pathname']
Apr 07 07:46:56 smartgarden python3[5222]: TRIGGER(S): ['url.pathname']
Apr 07 07:46:56 smartgarden python3[5222]: end= 2022-04-07 07:46:44
Apr 07 07:46:56 smartgarden python3[5222]: --------------------->>>>>>>>>>>>>>>>new page
Apr 07 07:46:56 smartgarden python3[5222]: begin= 2022-04-07 07:46:56
SG3 Service