From bf7ffca711cad7d068af81f4b7d26906ca8ed3b3 Mon Sep 17 00:00:00 2001 From: Cian Gallagher Date: Fri, 14 Jan 2022 20:59:10 +0000 Subject: [PATCH] EXAMPLES: Update systemd example and add launchctl example. --- examples/launchctl/README.md | 37 ++++++++++++++++++++++++++++ examples/systemd/README.md | 47 ++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 examples/launchctl/README.md diff --git a/examples/launchctl/README.md b/examples/launchctl/README.md new file mode 100644 index 0000000..4406947 --- /dev/null +++ b/examples/launchctl/README.md @@ -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 + + + + + Label + switchboard + ServiceDescription + File system watcher + ProgramArguments + + /usr/local/bin/switchboard + watch + --config + /path_to_your_config_file/config.yaml + + RunAtLoad + + + +``` + +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 +``` diff --git a/examples/systemd/README.md b/examples/systemd/README.md index 92c4636..ebf36ed 100644 --- a/examples/systemd/README.md +++ b/examples/systemd/README.md @@ -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.