-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EXAMPLES: Update systemd example and add launchctl example.
- Loading branch information
Showing
2 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# launchctl | ||
|
||
Below outlines an example for MacOS users using `launchctl`. launchctl will ensure switchboard is started and left running in the background, so you can get on with what you need to do. | ||
|
||
Create the following file `sudo touch /Library/LaunchDaemons/switchboard.plist` and copy and paste the contents below. Note, you should make any changes necessary to the arguments list, depending on how you want to use the tool. | ||
|
||
```bash | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!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>switchboard</string> | ||
<key>ServiceDescription</key> | ||
<string>File system watcher</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>/usr/local/bin/switchboard</string> | ||
<string>watch</string> | ||
<string>--config</string> | ||
<string>/path_to_your_config_file/config.yaml</string> | ||
</array> | ||
<key>RunAtLoad</key> | ||
<false/> | ||
</dict> | ||
</plist> | ||
``` | ||
|
||
Then, run the following commands to load, start, and list the running service and ensuring it has started. | ||
|
||
```bash | ||
sudo launchctl load /Library/LaunchDaemons/switchboard.plist | ||
sudo launchctl start switchboard | ||
|
||
sudo launchctl list | grep switchboard | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,46 @@ | ||
### Running Switchboard with systemd | ||
# SystemD | ||
|
||
Below outlines an example `systemd` configuration for switchboard. | ||
|
||
``` | ||
[Unit] | ||
Description=SWITCHBOARD demo service | ||
After=network.target | ||
StartLimitIntervalSec=0 | ||
[Service] | ||
Type=simple | ||
Restart=always | ||
RestartSec=1 | ||
User=pi | ||
ExecStart=switchboard watch --config /home/pi/config.yaml | ||
StandardOutput=append:/var/log/switchboard/log1.log | ||
StandardError=append:/var/log/switchboard/error1.log | ||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
Copy the above example and create a file called `switchboard.service` in `/etc/systemd/system` folder. | ||
|
||
!!! info | ||
You may need to create the log and error files ahead of time. | ||
|
||
### Start, Stop, Status and Reload Service | ||
|
||
You can stop, start, and reload the service using any of the following commands. | ||
|
||
- Start | ||
`systemctl start switchboard` | ||
|
||
- Reload | ||
`systemctl daemon-reload switchboard` | ||
|
||
- Stop | ||
`systemctl stop switchboard` | ||
|
||
- Status | ||
`systemctl status switchboard` | ||
|
||
|
||
Description TBD. |