Skip to content

Commit

Permalink
EXAMPLES: Update systemd example and add launchctl example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cian911 committed Jan 14, 2022
1 parent 113d879 commit bf7ffca
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
37 changes: 37 additions & 0 deletions examples/launchctl/README.md
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
```
47 changes: 45 additions & 2 deletions examples/systemd/README.md
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.

0 comments on commit bf7ffca

Please sign in to comment.