Weewx 3.9.2 starts and then exits abnormally at startup on MacOS Catalina but can be manually started just fine

65 views
Skip to first unread message

Geoff Harris

unread,
Mar 16, 2020, 10:34:33 AM3/16/20
to weewx-user
Hi,

I upgraded to 3.9.2 recently on Mac 10.15.3 and noticed that Weewx no longer successfully starts at startup. When I looked in the console I saw that during the startup it exits:
Mar 16 06:57:37 TV-Mac-mini com.apple.xpc.launchd[1] (com.weewx.weewxd[709]): Service exited with abnormal code: 1

I recopied the plist and checked the permissions, and restarted, but it still does not run Weewx


If I go to the terminal and run:


sudo launchctl load /Library/LaunchDaemons/com.weewx.weewxd.plist


it tells me the service is already running. If I then unload and then load, it runs just fine.


Thoughts on how to resolve this?


-Geoff

Geoff Harris

unread,
Mar 16, 2020, 3:00:17 PM3/16/20
to weewx-user
Replying to my own thread. 



I've had weewx running for a very long time on a different mac mini and already had a launchd plist as follows that I think M Wall authored:


<?xml version="1.0" encoding="UTF-8"?>
<!-- property list file for weewx daemon -->
<!-- put this file in /Library/LaunchDaemons -->
<!-- to start weewx: -->
<!--   sudo launchctl load -w /Library/LaunchDaemons/com.weewx.weewxd.plist -->
<!--   sudo launchctl unload /Library/LaunchDaemons/com.weewx.weewxd.plist -->
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.weewx.weewxd</string>
  <key>Disabled</key>
  <false/>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/Shared/weewx/bin/weewxd</string>
    <string>/Users/Shared/weewx/weewx.conf</string>
  </array>
</dict>
</plist>


The script that is included with weewx since 3.1.0 is below:


<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: com.weewx.weewxd.plist 2830 2015-01-06 04:13:39Z mwall $ -->
<!-- property list file for weewx daemon -->
<!-- put this file in /Library/LaunchDaemons -->
<!-- to start weewx: -->
<!--   sudo launchctl load -w /Library/LaunchDaemons/com.weewx.weewxd.plist -->
<!--   sudo launchctl unload /Library/LaunchDaemons/com.weewx.weewxd.plist -->
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.weewx.weewxd</string>
  <key>Disabled</key>
  <false/>
  <key>RunAtLoad</key>
  <true/>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/weewx/bin/weewxd</string>
    <string>/Users/weewx/weewx.conf</string>
  </array>
</dict>
</plist> 

As you can see, As you can see,<key>KeepAlive</key><true/> has been added. When Weewx starts at startup, it exits with error 4. With keep alive directive it respawns after 8 seconds. I don't know if it is the USB that becomes available after weewx tries to start or what condition needs to be satisfied, but on the respawn, the problem is solved.

Problem solved for now. Perhaps the plist for launchd should be updated to include KeepAlive?

-Geoff

mwall

unread,
Mar 16, 2020, 3:17:54 PM3/16/20
to weewx-user
On Monday, March 16, 2020 at 3:00:17 PM UTC-4, Geoff Harris wrote:
Problem solved for now. Perhaps the plist for launchd should be updated to include KeepAlive?

geoff,

KeepAlive is definitely NOT something we want in a default installation.  KeepAlive (and whatever the equivalent is for systemd) is a band-aid, not a cure.

the solution is to fix whatever is terminating the weewx process.

m

Geoff Harris

unread,
Mar 16, 2020, 4:31:08 PM3/16/20
to weewx-user
My recollection is that abnormal code 4 is when it can't connect to the USB. I can replicate the error by stopping weewx, unplugging the USB and starting it back up. With KeepAlive on , if i plug the device back in, it connects and behaves just like the startup. Not positive, but my best guess is that weewx is trying to load before the USB data logger (SLAB_UART) is available or for some reason it becomes temporarily unavailable after initial load. Since weewx dies immediately, I think it is likely that the USB is never seen. Thoughts on how to make the process wait for the USB logger to become available before loading up weewx? The fact that it also only does the KeepAlive cycle once at startup and then merrily works further supports this hypothesis. 

-Geoff

mwall

unread,
Mar 16, 2020, 5:10:53 PM3/16/20
to weewx-user


On Monday, March 16, 2020 at 4:31:08 PM UTC-4, Geoff Harris wrote:
My recollection is that abnormal code 4 is when it can't connect to the USB. I can replicate the error by stopping weewx, unplugging the USB and starting it back up.


geoff,

if this is just a startup issue, then you might want to try the loop_on_init option.

the normal startup behavior for weewx is to exit if it does not find the resources that it needs to operate.  this is to make it easier to debug/diagnose when you are invoking weewx directly.

these resources might be the usb, a sane time (from ntpd or whatever), networking, database server, etc.

when running weewx as a daemon, there are often cases where these other resources are not ready.  typically you would use the system's init dependencies to ensure availability.  however, sometimes that is not possible.

when loop_on_init=true then weewx will loop continually instead of exiting.

the log should tell you whether this will help - in your case, you should see a driver warning/error when it cannot find the usb.

if you see such a warning/failure repeatedly (not just at startup), then there is probably something funky with your usb.  KeepAlive will restart weewx for you, but it won't fix the problem.

if you see such a warning only once (just at startup), then there is probably nothing wrong with weewx or your usb, just timing.  loop_on_init should solve that.

we are pretty hard-nosed about the 'just reboot to fix it' and the keepalive or nanny script approaches to keep weewx running.  we would much rather fix the problems instead of applying layer after layer of band-aid.

m

Geoff Harris

unread,
Mar 16, 2020, 10:23:01 PM3/16/20
to weewx-user
Hi Mathew,

Took out KeepAlive from plist and added loop_on_init=True to weewx.conf file and this solved the problem. One could imagine having weewx try 2-5 times before giving up by default for just such a situation. Thank you for the clear help in getting to the bottom of the issue. Hope this helps somebody else.

-Geoff
Reply all
Reply to author
Forward
0 new messages