<<< macOS WeeWX Guides >>>
Run The Programme as a Service via Launchctl
All daemons, or cron jobs, in OSX are run and controled by the launchd process, which is in turn controlled by launchctl
At boot time the root launchd process will scan the daemon directories /System/Library/LaunchDaemons and /Library/LaunchDaemons for job definitions and load them depending on the existence/value of the Disabled key and the contents of the override database.
The launchd process runs a number of different jobs, depending on where you place the config file
Type | Location | Run on behalf of |
---|---|---|
User Agents | ~/Library/LaunchAgents | Currently logged in user |
Global Agents | /Library/LaunchAgents | Currently logged in user |
Global Daemons | /Library/LaunchDaemons | root or the user specified with the key User |
System Agents | /System/Library/LaunchAgents | Currently logged in user |
System Daemons | /System/Library/LaunchDaemons | root or the user specified with the key User |
As we want WeeWX to run all the time, we need to create a Global Daemon. If you want to work this out for yourself there are some excellent tutorials on the MAC developers website
If you just want it to work then follow these steps.
- Create a directory somewhere on your server
- I put mine on the same drive as my website, but in a protected directory
- Download and copy these files to that directory
- Then edit all of the files so that they point to the location of your website files and the directory where you put the downloaded files
- Check the file weewx_wrapper.sh
- This checks to make sure that the process is running properly and restarts it if it has failed
- To do this it checks the USB port that is being used to communicate with your weather station.
- I am using a Davis Vantage Vue, which uses the following USB driver
- /dev/tty.SLAB_USBtoUART
- You will need to adjust this to the correct port for your system
- Once all the files are modified
- Copy com.weewx.weewxd.plist into /Library/LaunchDaemons
- Run StartWeewx
- Run CheckWeewx to test
- the output should look something like this
$ ./CheckWeewx { "StandardOutPath" = "/Library/Logs/weewx.log"; "LimitLoadToSessionType" = "System"; "StandardErrorPath" = "/Library/Logs/weewx_error.log"; "Label" = "com.weewx.weewxd"; "TimeOut" = 30; "OnDemand" = false; "LastExitStatus" = 0; "PID" = 76251; "Program" = "/Groups/revitt/Daemons/weewx_wrapper.sh"; "ProgramArguments" = ( "/Groups/revitt/Daemons/weewx_wrapper.sh"; "/usr/bin/python"; "/Groups/revitt/WebSites/Weewx/bin/weewxd.py"; "/Groups/revitt/WebSites/Weewx/weewx.conf"; "--exit"; ); };