|
Post by doxidad on Apr 7, 2021 10:05:42 GMT -8
No, I'm not familiar. There are some folks here that are familiar with node-red. Not exactly sure who, but I have seen some mention of it in messoages. Maybe someone will see this discussion and contact you and help you out.
|
|
herve
Junior Member
Posts: 54
|
Post by herve on Apr 7, 2021 12:08:22 GMT -8
Thanks Jason!
Hervé
|
|
|
Post by Jason on Apr 7, 2021 12:29:50 GMT -8
I’ve setup InfluxDB on my RPi cluster but haven’t had the time to really dig into working with it. Fortunately, Grafana plays nicely with RDBMS like PostgreSQL and MariaDB assuming time stamps are stored as UTC time stamps. Jason
|
|
herve
Junior Member
Posts: 54
|
Post by herve on Apr 8, 2021 6:53:01 GMT -8
I keep having problems starting up my SkyWeather2 after rebooting via rc.local.
When I start SkyWeather2.py and index.py via the command line in Putty, everything runs normally: in the dashboard I see green LEDs and the weather data are being refreshed. But when I reboot my RPi nothing works anymore.
When check with
ps ax | grep index.py | grep -v grep
and
ps ax | grep SkyWeather2.py | grep -v grep
or with
ps -aux | grep python
I don't see anything appear. So those python files are not started.
I no longer know how to proceed with this. And as long as I can't fix this, I can't get my SkyWeather2 to a final location.
For my RPi I use Buster as OS. Could it be that my rc.local does not work in Buster?
To be clear, this is my rc.local:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
cd /home/pi/SDL_Pi_Skyweather2
nohup sudo python3 SkyWeather2.py &
chmod 666 nohup.out
cd /home/pi/SDL_Pi_SkyWeather2/dash_app
nohup sudo python3 index.py &
chmod 666 nohup.out
exit 0
I hope someone can help me.
Hervé
|
|
|
Post by doxidad on Apr 8, 2021 10:32:28 GMT -8
Hervé,
What is the protection on rc.local use the ls -l command to display it.
pi@WPI2:~ $ ls -l /etc/rc.local -rwxr-xr-x 1 root root 420 Jan 11 07:55 /etc/rc.local
If the execute bit is not set it won't run.
The 'x's in the mask show that owner, group and world all can execute this file
If the protection mask is not what is shown above use this command to fix it so it is executable.
sudo chmod 755 /etc/rc.local
If the protection was correct - I'm not sure what's causing them to not start up.
|
|
herve
Junior Member
Posts: 54
|
Post by herve on Apr 8, 2021 11:30:44 GMT -8
Hi doxidad
ls -l /etc/rc/local gives:
-rwxr-xr-x 1 root root 599 apr 8 16:20 /etc/rc.local
So that seems to be normal. But maybe I am doing something completely wrong?
- I start Putty and open a session on the IP address of my SkyWeather2.
- via the command line I start SkyWeather2.py
- after about an hour I start a new Putty session in which I open the dashboard with index.py via the command line
On the dashboard everything is fine: SkyWeather Status shows green LEDs and the weather data are regularly updated
- I end both Putty sessions
- I do a reboot and from then on it goes wrong:
When I open a new Py-utty session and check if rc.local has worked with ps ax | grep SkyWeather2.py | grep -v grep
and with ps ax | grep index.py | grep -v grep
I get no response.
So I think the python files SkyWeather2.py and index.py did not start And therefore the dashboard is of course also not accessible.
What am I doing wrong? Frustration starts to play tricks on me...
Hervé
|
|
|
Post by Jason on Apr 8, 2021 12:56:04 GMT -8
I can post instructions on how to setup the SkyWeather2 and Dash app as Linux services using systemctl if you are interested. I’m not a fan of rc.local so use systemctl directly instead. Much easier in my humble opinion.
Thanks,
Jason
|
|
|
Post by doxidad on Apr 8, 2021 13:11:51 GMT -8
I don't use the rc.local to start my skyweather programs either - I set both of the programs up as services. There is a bit more editing and so forth but can start/stop and check status at will.
|
|
|
Post by SDL on Apr 8, 2021 13:14:13 GMT -8
Hi doxidad ls -l /etc/rc/local gives: -rwxr-xr-x 1 root root 599 apr 8 16:20 /etc/rc.localSo that seems to be normal. But maybe I am doing something completely wrong? - I start Putty and open a session on the IP address of my SkyWeather2. - via the command line I start SkyWeather2.py - after about an hour I start a new Putty session in which I open the dashboard with index.py via the command line On the dashboard everything is fine: SkyWeather Status shows green LEDs and the weather data are regularly updated - I end both Putty sessions - I do a reboot and from then on it goes wrong: When I open a new Py-utty session and check if rc.local has worked with ps ax | grep SkyWeather2.py | grep -v grep and with ps ax | grep index.py | grep -v grep I get no response. So I think the python files SkyWeather2.py and index.py did not start And therefore the dashboard is of course also not accessible. What am I doing wrong? Frustration starts to play tricks on me... Hervé Please post the results when you say "no response" Show the screen shot. Try the more general: sudo ps xaf | grep python and post the results. BP
|
|
herve
Junior Member
Posts: 54
|
Post by herve on Apr 8, 2021 13:31:05 GMT -8
Jason
I am definitely interested in using systemctl instead of rc.local. But may I ask you to give me some explanation, because I am not a Linux connoisseur and not a programmer. I hope your method solves my annoying startup problem.
|
|
herve
Junior Member
Posts: 54
|
Post by herve on Apr 8, 2021 13:58:47 GMT -8
Hello BP You asked me: "Please post the results when you say "no response" Show the screen shot. Try the more general: sudo ps xaf | grep python and post the results. BP" That's what I get: pi@SwitchDoc:~ $ ps ax | grep SkyWeather2.py | grep -v grep pi@SwitchDoc:~ $ ps ax | grep index.py | grep -v grep pi@SwitchDoc:~ $ sudo ps ax | grep SkyWeather2.py | grep -v grep pi@SwitchDoc:~ $ sudo ps ax | grep index.py | grep -v grep So, no response And with sudo ps xaf | grep python I get: pi@SwitchDoc:~ $ sudo ps xaf | grep python 1055 pts/0 S+ 0:00 \_ grep --color=auto python Herve
|
|
herve
Junior Member
Posts: 54
|
Post by herve on Apr 8, 2021 14:04:01 GMT -8
Hello doxidad
You said: "I don't use the rc.local to start my skyweather programs either - I set both of the programs up as services. There is a bit more editing and so forth but can start/stop and check status at will."
I am definitely interested in your method instead of rc.local. But may I ask you to give some explanation, because I am not a Linux connoisseur and not a programmer. I hope your method solves my annoying startup problem.
Herve
|
|
|
Post by Jason on Apr 8, 2021 14:16:12 GMT -8
1. cd to your SkyWeather2 directory 2. sudo mkdir logs 3. sudo chmod 777 ./logs 4. sudo nano skyweather2.service
Add the following contents to the service file:
[Unit] Description=SkyWeather2 After=network.target
[Service] Type=simple User=root Group=root StandardOutput=file:/YOUR-PATH/SDL_Pi_SkyWeather2/logs/skyweather2.out StandardError=file: /YOUR-PATH/SDL_Pi_SkyWeather2/logs/skyweather2.err WorkingDirectory= /YOUR-PATH/SDL_Pi_SkyWeather2 ExecStart=/usr/bin/python3 /YOUR-PATH/SDL_Pi_SkyWeather2/SkyWeather2.py
[Install] WantedBy=multi-user.target
Make sure the directory structure in your service file matches the file system. Save and close the service file.
5. sudo ln -sf /YOUR-PATH/SDL_Pi_SkyWeather2/skyweather2.service /etc/systemd/system/skyweather2.service 6. sudo systemctl daemon-reload 7. sudo systemctl enable skyweather2 8. sudo systemctl start skyweather2
Step 5 creates a symlink to your service file in the directory that systemd uses.
Step 6 reloads the systemd daemon to use the new service definition
Step 7 enables the service to start at boot
Step 8 starts the service to run the SkyWeather2.
You can check the status of the service by typing sudo systemctl status skyweather2.
You can also stop the service by typing sudo systemctl stop skyweather2
Thanks,
Jason
P.S. I’m posting this from my phone so hopefully I caught all the autocorrect mistakes.
|
|
herve
Junior Member
Posts: 54
|
Post by herve on Apr 8, 2021 14:53:12 GMT -8
Hello Jason i will give it a try tomorrow (it's now 0.49 a.m here in Belgium - so midnight) and update you on the result In any case, thank you very much for your help
Herve
|
|
|
Post by Jason on Apr 8, 2021 15:36:56 GMT -8
Forgot to mention the Dash app. You’ll need a second service file. I believe I named mine sw2dash.service. The contents should be similar to what follows.
[Unit] Description=SkyWeather2 Dash Application After=network.target
[Service] Type=simple User=root Group=root StandardOutput=file:/YOUR-PATH/SDL_Pi_SkyWeather2/dash_app/logs/sw2dash.out StandardError=file:/YOUR-PATH/SDL_Pi_SkyWeather2/dash_app/logs/sw2dash.err WorkingDirectory=/YOUR-PATH/SDL_Pi_SkyWeather2/dash_app ExecStart=/usr/bin/python3 /YOUR-PATH/SDL_Pi_SkyWeather2/dash_app/index.py
[Install] WantedBy=multi-user.target
Instructions above apply to this service definition as well.
Thanks,
Jason
P.S. I’m not certain this is the best way to run a Dash app. However, I have not investigated alternatives such as gunicorn.
|
|