Weewx Service with Systemd Raspbian Jessie

474 views
Skip to first unread message

Horacio

unread,
Jun 10, 2015, 1:58:58 PM6/10/15
to weewx...@googlegroups.com
Hello!

Since last week debian jessie is now stable, so I’m evaluating to upgrade all my rpi images to raspbian jessie.

Does anybody have any advice about the weewx service update to systemd?

Thanks in advance.
H

mwall

unread,
Jun 10, 2015, 2:03:43 PM6/10/15
to weewx...@googlegroups.com, rose...@gmail.com
On Wednesday, June 10, 2015 at 1:58:58 PM UTC-4, Horacio wrote:
Does anybody have any advice about the weewx service update to systemd?

the init.d scripts that ship with weewx already work with systemd.  however, if you want a weewx service file, try this:

https://raw.githubusercontent.com/weewx/weewx/master/util/systemd/weewx.service

it is in the util directory of the weewx distribution.

m

vince

unread,
Jun 10, 2015, 2:09:15 PM6/10/15
to weewx...@googlegroups.com, rose...@gmail.com

It would be great to hear another systemd user report.   If you start up using the github weewx.service file Matthew mentioned, can you check your logs to see what your syslog looks like.  Mine seems to start up logging like it was running in the foreground (every LOOP packet) but when I stop+start weewx it logs like it's running in the background (as expected).

I'm wondering if the weewx.service file Matthew mentions still needs a little tweaking for Debian....
 
(but as he said, the init.d file 'does' work fine still on Debian 8 if you want to use that way)

mwall

unread,
Jun 10, 2015, 2:29:50 PM6/10/15
to weewx...@googlegroups.com, vince...@gmail.com, rose...@gmail.com
On Wednesday, June 10, 2015 at 2:09:15 PM UTC-4, vince wrote:
It would be great to hear another systemd user report.   If you start up using the github weewx.service file Matthew mentioned, can you check your logs to see what your syslog looks like.  Mine seems to start up logging like it was running in the foreground (every LOOP packet) but when I stop+start weewx it logs like it's running in the background (as expected).
 
 I'm wondering if the weewx.service file Matthew mentions still needs a little tweaking for Debian....

vince,

try the latest weewx.service file (commit 38f3f9c280e9a1b0240b16ab68ea3fa9af21dbe8).  i added the --daemon and --pidfile options to ExecStart.  i suspect the lack of --daemon option might be causing the behavior you see.

m

vince

unread,
Jun 10, 2015, 2:45:24 PM6/10/15
to weewx...@googlegroups.com, vince...@gmail.com, rose...@gmail.com
vince,

try the latest weewx.service file (commit 38f3f9c280e9a1b0240b16ab68ea3fa9af21dbe8).  i added the --daemon and --pidfile options to ExecStart.  i suspect the lack of --daemon option might be causing the behavior you see.



new one looks great - dropped it into place in /etc/systemctl/system and rebooted (to do a clean bootup) and it fired up just fine.  Thanks !

Horacio

unread,
Jun 10, 2015, 3:53:30 PM6/10/15
to weewx...@googlegroups.com
Thanks Matthew and Vince for your quick answer. Rpi is upgrading now, I'll let you know how it has gone
Regards
H

Horacio

unread,
Jun 11, 2015, 3:06:46 PM6/11/15
to weewx...@googlegroups.com
Hello

It took a lifetime to upgrade to raspbian jessie but the rpi finally did it. Weewx (standard init service) works well without any modifications.

I went a little bit further and created a "weewx.service" file in "/lib/systemd/system" almost like Matthew posted here yesterday. I moved the old "weewx" init file from "/etc/init.d" to "/home/pi" and left it there as a backup.

# systemd configuration for weewx

[Unit]
Description=WEEWX Service
Requires=systemd-journald.service
Requires=ntp.service
Requires=bluetooth.service
Requires=rfcomm.service
After=systemd-journald.service
After=ntp.service
After=bluetooth.service
After=rfcomm.service

[Service]
ExecStart=/usr/share/weewx/weewxd --daemon --pidfile=/var/run/weewx.pid /etc/weewx/weewx.conf
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
PIDFile=/var/run/weewx.pid

[Install]
WantedBy=multi-user.target

As my "WS1" weather station is connected via bluetooth I added the bluetooth and rfcomm dependencies. By the way, the bluetooth stack changed and as far as I know "rfcomm.conf" file is not an option anymore, so I had to create a new service for it.

To enable, start and check weewx service:
sudo systemctl enable weewx
sudo systemctl start weewx
sudo systemctl status weewx

● weewx.service - WEEWX Service
   Loaded: loaded (/lib/systemd/system/weewx.service; enabled)
   Active: active (running) since Thu 2015-06-11 15:53:04 ART; 4min 5s ago
 Main PID: 570 (python)
   CGroup: /system.slice/weewx.service
           └─570 python /usr/share/weewx/weewxd --daemon --pidfile=/var/run/weewx.pid /etc/weewx/weewx.conf

Jun 11 15:57:06 PiPlantino weewx[570]: ws1: close serial port /dev/rfcomm0
Jun 11 15:57:06 PiPlantino weewx[570]: ws1: open serial port /dev/rfcomm0
Jun 11 15:57:07 PiPlantino weewx[570]: ws1: close serial port /dev/rfcomm0

I removed rsyslog also because journald is now active and it's very nice.
We can execute "sudo journalctl -f -u weewx" instead of "tail -f /var/log/syslog".

Rsyslog has a small bug after the update. It's constantly showing "rsyslogd-2007: action 'action 17' suspended". It's already reported and not fixed so I decided to remove it.  

That's all.
Regards!

H

On Wednesday, June 10, 2015 at 2:58:58 PM UTC-3, Horacio wrote:

Deborah Pickett

unread,
Jun 16, 2015, 7:19:10 AM6/16/15
to weewx...@googlegroups.com
On Thursday, June 11, 2015 at 3:58:58 AM UTC+10, Horacio wrote:
Does anybody have any advice about the weewx service update to systemd?

Here's my configuration for Debian jessie (x86-64 not Raspberry Pi).  It's copied from mwall's version in GitHub and modified a bit.

/etc/udev/rules.d/90-vantage.rules:
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="vantage", TAG+="systemd", ENV{SYSTEMD_WANTS}="weewx.service"

/lib/systemd/system/weewx.service:
[Unit]
Description=weewx weather system
Requires=syslog.service
Requires=ntp.service
After=syslog.service
After=ntp.service
RequiresMountsFor=/home
BindsTo=dev-vantage.device
After=dev-vantage.device

[Service]
ExecStart=/
home/weewx/bin/weewxd --daemon --pidfile=/run/weewx/weewx.pid /home/weewx/weewx.conf
ExecReload=/bin/kill -HUP $MAINPID
Type=forking
PIDFile=/run/weewx/weewx.pid
RuntimeDirectory=weewx
User=weewx
Group=weewx

[Install]
WantedBy=multi-user.target

A couple of notes:
  • The udev rule just makes a /dev/vantage symlink which is what I list in weewx.conf as the serial port.  The mentions of systemd in the udev rule ensure that the weewx.service service gets started whenever the USB cable is plugged in.
  • The BindsTo mention in [Unit] ensure that the service exits when the cable is disconnected.  The After may be unnecessary in this case but I see it in examples.
  • I changed the [Service] Type back to forking.  systemd copes with Type=simple but I think Type=forking more closely matches the current weewx command line.
  • I've added RuntimeDirectory and added an extra directory level to the pidfile path because I run weewx as an unprivileged user which wouldn't have write access to /run; with this option systemd creates a subdirectory owned by the weewx user.
Reply all
Reply to author
Forward
0 new messages