On Thursday, March 14, 2019 at 1:43:55 PM UTC-5, jmviper wrote:
>
>
> I have basics in linux so I have some idea about systemd (I've heard of 
> it) but I don't know much of it
>>
>>
> I have contrab restarting weewx every three hours but with no success when 
> this issue happens.
>
> If you wish you can share your code just to test and perhaps to help 
> someone else.
>
> Thanks
>

OK. If you want to get a better understanding of systemd and what you are 
doing, I suggest you read the excellent article by Justin Ellingwood at 
https://www.digitalocean.com/community/tutorials/systemd-essentials-working-with-services-units-and-the-journal,
 
together with the continuation articles which are linked to in its 'Next 
Steps' section. The weewx Wiki also includes a brief and (IMHO) somewhat 
limited discussion of using systemd to run weewx at 
https://github.com/weewx/weewx/wiki/systemd. The process which I am about 
to describe draws and expands somewhat on that.
If you are going to use systemd directly to run weewx, you firat need to 
stop weewx and to disable and remove the configuration setup that normally 
uses sysv to run it automatically, as follows:

sudo /etc/init.d/weewx stop
sudo update-rc.d weewx remove
sudo rm /etc/init.d/weewx

You then need to create a systemd 'unit' file called 
/etc/systemd/system/weewx.service. Creating this requires root/su 
privileges, so you will need to use 'sudo' with your editor of choice. An 
example file is to be found at 
https://github.com/weewx/weewx/blob/master/util/systemd/weewx.service. Note 
that a number of file paths specified in the example file may need to be 
adjusted to correspond to where things are in your setup. I used the 
following version of the file, which includes a couple of additional 
parameters which I found necessary to get weewx to restart reliably after 
crashing. They are explained in the article I referred to first and in the 
man pages for systemd.

# systemd configuration for weewx

[Unit]
Description=weewx weather system
Requires=time-sync.target
After=time-sync.target
RequiresMountsFor=/home

[Service]
# the first and last filepaths in the next line may need to be modified, 
depending
# on where weewx's code and configuration files are on your system
ExecStart=/usr/bin/weewxd --daemon --pidfile=/var/run/weewx.pid 
/etc/weewx/weewx.conf
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
PIDFile=/var/run/weewx.pid
# the next two lines are my additions to the file from he distribution
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Once you have created and checked the 'unit' file, you restart weewx as 
follows:

sudo systemctl enable weewx.service
sudo systemctl start weewx.service

weewx should now be running again and will be restarted automatically 
if/when the system reboots or if it fails while running. 

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to