-
Notifications
You must be signed in to change notification settings - Fork 18
Starting Watcher automatically
Create a file called net.nosmokingbandit.watcher.plist in your ~/Library/LaunchAgents directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>watcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>watcher.py</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/watcher</string>
</dict>
</plist>
Change line 21 to the absolute path of your watcher folder Make sure your watcher folder matches your user permissions (otherwise the launchd service might fail to start):
sudo chown -R $(whoami) /opt/watcher (change this path to the path of your watcher folder from above)
In Terminal:
To enable the daemon: launchctl load ~/Library/LaunchAgents/net.nosmokingbandit.watcher.plist
To disable the daemon: launchctl unload ~/Library/LaunchAgents/net.nosmokingbandit.watcher.plist
Enjoy! This will automatically start watcher when you login
Create a file called net.nosmokingbandit.watcher.plist in your /Library/LaunchAgents directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>watcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>watcher.py</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/opt/watcher</string>
</dict>
</plist>
Change line 21 to the absolute path of your watcher folder In Terminal:
To enable the daemon: sudo launchctl load /Library/LaunchAgents/net.nosmokingbandit.watcher.plist
To disable the daemon: sudo launchctl unload /Library/LaunchAgents/net.nosmokingbandit.watcher.plist
Enjoy! This will automatically start watcher when your machine boots
You will need to create the watcher3 folder, watcher.pid, db folder, logs folder, and plugins folders under the user you will start the service under in the .config folder.
Assuming the Watcher3 install is in /opt/Watcher3
sudo nano /etc/systemd/system/watcher\@.service
[Unit]
Description=Watcher3
After=network.target
[Service]
User=%I
Group=%I
Type=forking
ExecStart=/usr/bin/python3 /opt/Watcher3/watcher.py --daemon --conf /home/%I/.config/watcher3/watcher.cfg --db /home/%I/.config/watcher3/db/database.sqlite --log /home/%I/.config/watcher3/logs/ --plugins /home/%I/.config/watcher3/plugins/ --pid /home/%I/.config/watcher3/watcher.pid
Restart=on-failure
TimeoutStopSec=300
PIDFile=/home/%I/.config/watcher3/watcher.pid
[Install]
WantedBy=multi-user.target
Change #USER# with the user you want the run the service as
sudo systemctl daemon-reload
sudo systemctl enable watcher@#USER#
sudo systemctl start watcher@#USER#