From d32b7bdd4449fb90ab03a7c84b50eb6171d11413 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 26 Jun 2020 06:32:22 +0000 Subject: [PATCH] update docs --- serviceman/README.md | 78 +++++++++++++++++++++++++++++++++++++++++++ serviceman/install.sh | 71 +++++++++++++-------------------------- 2 files changed, 101 insertions(+), 48 deletions(-) create mode 100644 serviceman/README.md diff --git a/serviceman/README.md b/serviceman/README.md new file mode 100644 index 0000000..497bf1f --- /dev/null +++ b/serviceman/README.md @@ -0,0 +1,78 @@ +--- +title: Serviceman +homepage: https://git.rootprojects.org/root/serviceman +tagline: | + Serviceman: cross-platform service management for Linux, Mac, and Windows. +description: | + Serviceman is a hassle-free wrapper around your system launcher. It works with the default system launcher to make it easy to start _user_- and _system_-level services, such as webservers, backup scripts, network and system tools, etc. + + Supports + - `launchctl` (macOS) + - `systemctl` (Linux) + - The Registry (Windows) +--- + +Serviceman can run an app in just about any programming language very simply. + +If you'd like to learn what `serviceman` does without actually making changes, +add the `--dry-run` option. + +### Node.js + +**Development Server** + +```bash +pushd ./my-node-app/ +sudo env PATH="$PATH" \ + serviceman add --cap-net-bind --system npx nodemon +``` + +**Production Server** + +```bash +pushd ./my-node-app/ +sudo env PATH="$PATH" \ + serviceman add --cap-net-bind --system npm start +``` + +### Golang + +```bash +pushd ./my-go-package/ +sudo env PATH="$PATH" \ + serviceman add --system go run -mod=vendor cmd/my-service/*.go --port 3000 +``` + +```bash +pushd ./my-go-package/ +go build -mod=vendor cmd/my-service +sudo env PATH="$PATH" \ + serviceman add --cap-net-bind --system ./my-service --port 80 +``` + +### And even bash! + +```bash +sudo env PATH="$PATH" serviceman add bash ./backup.sh /mnt/data +``` + +### Use `--dry-run` to see the generated launcher config: + +```bash +sudo env PATH="$PATH" \ + serviceman add --dryrun bash ./backup.sh /mnt/data +``` + +### See the (sub)command help + +The main help, showing all subcommands: + +```bash +serviceman --help +``` + +Sub-command specific help: + +```bash +serviceman add --help +``` diff --git a/serviceman/install.sh b/serviceman/install.sh index 690d44a..06ed1e7 100644 --- a/serviceman/install.sh +++ b/serviceman/install.sh @@ -1,54 +1,29 @@ #!/bin/bash -# title: Serviceman -# homepage: https://git.rootprojects.org/root/serviceman -# tagline: | -# Serviceman: cross-platform service management for Linux, Mac, and Windows. -# description: | -# Serviceman is a hassle-free wrapper around your system launcher. It works with `launchctl` (macOS), `systemctl` (Linux), and the Windows Registry to make it easy to start _user_ and _system_ level services, such as webservers, backup scripts, network and system tools, etc. -# examples: | -# -# Works with anything, including -# -# ### Node.js -# -# ```bash -# serviceman add --name my-service node ./serve.js --port 3000 -# ``` -# -# ### Golang -# -# ```bash -# go build -mod vendor cmd/my-service -# serviceman add ./my-service --port 3000 -# ``` -# -# ### And even bash! -# -# ```bash -# serviceman add --name backuper bash ./backup.sh /mnt/data -# ``` +{ -set -e -set -u + set -e + set -u -# Test if in PATH -set +e -my_serviceman=$(command -v serviceman) -set -e -if [ -n "$my_serviceman" ]; then - if [ "$my_serviceman" != "$HOME/.local/bin/serviceman" ]; then - echo "a serviceman installation (which make take precedence) exists at:" - echo " $my_serviceman" - echo "" - fi -fi + # Test if in PATH + set +e + my_serviceman=$(command -v serviceman) + set -e + if [ -n "$my_serviceman" ]; then + if [ "$my_serviceman" != "$HOME/.local/bin/serviceman" ]; then + echo "a serviceman installation (which make take precedence) exists at:" + echo " $my_serviceman" + echo "" + fi + fi -# Get arch envs, etc -webi_download "https://rootprojects.org/serviceman/dist/$(uname -s)/$(uname -m)/serviceman" "$HOME/Downloads/serviceman" -chmod +x "$HOME/Downloads/serviceman" -mv "$HOME/Downloads/serviceman" "$HOME/.local/bin/" + # Get arch envs, etc + webi_download "https://rootprojects.org/serviceman/dist/$(uname -s)/$(uname -m)/serviceman" "$HOME/Downloads/serviceman" + chmod +x "$HOME/Downloads/serviceman" + mv "$HOME/Downloads/serviceman" "$HOME/.local/bin/" -# add to ~/.local/bin to PATH, just in case -webi_path_add $HOME/.local/bin # > /dev/null 2> /dev/null -# TODO inform user to add to path, apart from pathman? + # add to ~/.local/bin to PATH, just in case + webi_path_add $HOME/.local/bin # > /dev/null 2> /dev/null + # TODO inform user to add to path, apart from pathman? + +} -- 2.25.1