diff --git a/brew/brew-update-service-install b/brew/brew-update-service-install index 0e72d16d9..262b95c0c 100644 --- a/brew/brew-update-service-install +++ b/brew/brew-update-service-install @@ -7,11 +7,11 @@ main() { ( chmod a+x ~/.local/bin/brew-update-hourly echo "Checking for serviceman..." + ~/.local/bin/webi serviceman if ! command -v serviceman > /dev/null; then - "$HOME/.local/bin/webi" serviceman export PATH="$HOME/.local/bin:$PATH" - serviceman --version fi + serviceman --version env PATH="$PATH" serviceman add --agent \ --workdir ~/.local/opt/brew/ \ diff --git a/bun/README.md b/bun/README.md index 431e87cb5..e688ebd60 100644 --- a/bun/README.md +++ b/bun/README.md @@ -132,9 +132,7 @@ file) ``` 3. Add your project to the system launcher, running as the current user ```sh - sudo env PATH="$PATH" \ - serviceman add --path="$PATH" --system \ - --username "$(whoami)" --name my-project -- \ + serviceman add --name 'my-project' --daemon -- \ bun run ./my-project.js ``` 4. Restart the logging service @@ -155,6 +153,6 @@ For **macOS**: ``` 3. Add your project to the system launcher, running as the current user ```sh - serviceman add --path="$PATH" --agent --name my-project -- \ + serviceman add --agent --name 'my-project' -- \ bun run ./my-project.js ``` diff --git a/caddy/README.md b/caddy/README.md index 2c2e65f70..1425f280a 100644 --- a/caddy/README.md +++ b/caddy/README.md @@ -821,8 +821,8 @@ To avoid the nitty-gritty details of `launchd` plist files, you can use ```sh my_username="$( id -u -n )" - serviceman add --agent --name caddy -- \ - caddy run --config ./Caddyfile --envfile ~/.config/caddy/env + serviceman add --agent --name 'caddy' --workdir ./ -- \ + caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile ``` (this will create `~/Library/LaunchAgents/caddy.plist`) @@ -837,8 +837,8 @@ This process creates a _User-Level_ service in `~/Library/LaunchAgents`. To create a _System-Level_ service in `/Library/LaunchDaemons/` instead: ```sh -sudo serviceman add --system --name caddy -- \ - caddy run --config ./Caddyfile --envfile ~/.config/caddy/env +serviceman add --name 'caddy' --workdir ./ --daemon -- \ + caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile ``` ### How to run Caddy as a Windows Service @@ -856,7 +856,7 @@ sudo serviceman add --system --name caddy -- \ 3. Create a **Startup Registry Entry** with Serviceman. ```sh serviceman.exe add --name caddy -- \ - caddy run --config ./Caddyfile --envfile ~/.config/caddy/env + caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile ``` 4. You can manage the service directly with Serviceman. For example: ```sh @@ -901,10 +901,8 @@ See the notes below to run as a **User Service** or use the JSON Config. ``` 4. Use Serviceman to create a _systemd_ config file. ```sh - my_username="$( id -u -n )" - sudo env PATH="$PATH" \ - serviceman add --system --username "${my_username}" --name caddy -- \ - caddy run --config ./Caddyfile --envfile ~/.config/caddy/env + serviceman add --name 'caddy' --daemon -- \ + caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile ``` (this will create `/etc/systemd/system/caddy.service`) 5. Manage the service with `systemctl` and `journalctl`: @@ -915,10 +913,10 @@ See the notes below to run as a **User Service** or use the JSON Config. To create a **User Service** instead: -- don't use `sudo`, but do use `--agent` when running `serviceman`: +- use `--agent` when running `serviceman`: ```sh serviceman add --agent --name caddy -- \ - caddy run --config ./Caddyfile --envfile ~/.config/caddy/env + caddy run --envfile ~/.config/caddy/env --config ./Caddyfile --adapter caddyfile ``` (this will create `~/.config/systemd/user/`) - user the `--user` flag to manage services and logs: @@ -1183,7 +1181,8 @@ To prevent search engine and browser confusion - _DO NOT_ prevent crawling via `robots.txt` \ (counter-intuitive, but pages _must_ be crawled for links to _NOT_ be indexed) - _all_ domains using public TLS certs _will_ be indexed by default \ - (they are all linked to and crawled from various Certificate Transparency reports) + (they are all linked to and crawled from various Certificate Transparency + reports) - follow these guidelines even if the dev sites use HTTP Basic Auth ```Caddyfile @@ -1363,19 +1362,13 @@ See also: 2. Generate the `service` file: \ - JSON Config ```sh - my_app_user="$( id -u -n )" - sudo env PATH="${PATH}" \ - serviceman add --system --cap-net-bind \ - --username "${my_app_user}" --name caddy -- \ - caddy run --resume --envfile ./caddy.env + serviceman add --name 'caddy' --daemon -- \ + caddy run --resume --envfile ./caddy.env ``` - Caddyfile ```sh - my_app_user="$( id -u -n )" - sudo env PATH="${PATH}" \ - serviceman add --system --cap-net-bind \ - --username "${my_app_user}" --name caddy -- \ - caddy run --config ./Caddyfile --envfile ./caddy.env + serviceman add --name 'caddy' --daemon -- \ + caddy run --config ./Caddyfile --envfile ./caddy.env ``` 3. Reload `systemd` config files, the logging service (it may not be started on a new VPS), and caddy diff --git a/dashcore-utils/README.md b/dashcore-utils/README.md index 41c54edcc..f2e3d4d08 100644 --- a/dashcore-utils/README.md +++ b/dashcore-utils/README.md @@ -100,8 +100,7 @@ mkdir -p ~/.dashcore/wallets/ mkdir -p /mnt/slc1_vol_100g/dashcore/_data mkdir -p /mnt/slc1_vol_100g/dashcore/_caches -sudo env PATH="$PATH" serviceman add \ - --system --user "$my_user" --path "$PATH" --name dashd --force -- \ +serviceman add --name 'dashd' --daemon -- \ dashd \ -usehd \ -conf="$HOME/.dashcore/dash.conf" \ diff --git a/dashcore-utils/dashd-hd-service-install b/dashcore-utils/dashd-hd-service-install index 13aa9b299..ce9b65e92 100644 --- a/dashcore-utils/dashd-hd-service-install +++ b/dashcore-utils/dashd-hd-service-install @@ -84,20 +84,8 @@ fn_srv_install() { ( my_name="dashd-${my_netname}" fi - my_system_args="" - my_kernel="$( - uname -s - )" - if test "Darwin" != "${my_kernel}"; then - my_user="$( - id -u -n - )" - my_system_args="--system --username ${my_user}" - fi - # shellcheck disable=SC2016,SC1090 - echo 'sudo env PATH="$PATH"' \ - "serviceman add ${my_system_args} --path \"\$PATH\" --name \"${my_name}\" --force --" \ + echo "serviceman add --name \"${my_name}\" --" \ "dashd " \ "${my_net_flag}" \ -usehd \ @@ -107,16 +95,16 @@ fn_srv_install() { ( "-datadir=\"${my_datadir}\"" \ "-blocksdir=\"${my_blocksdir}\"" + echo "" + echo "Installing latest 'serviceman'..." + echo "" + "$HOME/.local/bin/webi" serviceman > /dev/null if ! command -v serviceman > /dev/null; then - echo "" - echo "Installing 'serviceman'..." - echo "" - { - "$HOME/.local/bin/webi" serviceman - } > /dev/null - - # shellcheck disable=SC1090 - . ~/.config/envman/PATH.env || true + export PATH="$HOME/.local/bin:$PATH" + fi + serviceman --version + if ! command -v dashd > /dev/null; then + export PATH="$HOME/.local/opt/dashcore/bin:$PATH" fi mkdir -p "$HOME/.dashcore/wallets/" @@ -132,7 +120,7 @@ fn_srv_install() { ( # leave options unquoted so they're interpreted separately # shellcheck disable=SC2086 sudo env PATH="${PATH}" \ - serviceman add ${my_system_args} --path "${PATH}" --name "${my_name}" --force -- \ + serviceman add --name "${my_name}" -- \ dashd \ ${my_net_flag} \ -usehd \ diff --git a/dashd/README.md b/dashd/README.md index 2dd32d413..a89ce5675 100644 --- a/dashd/README.md +++ b/dashd/README.md @@ -219,14 +219,7 @@ You can use [`serviceman`](../serviceman/): **Linux** ```sh -sudo env PATH="$PATH" \ - serviceman add \ - --system \ - --username "$(id -n -u)" \ - --path "$PATH" \ - --name dashd \ - --force \ - -- \ +serviceman add --name 'dashd' -- \ dashd \ -usehd \ -conf="$HOME/.dashcore/dash.conf" \ @@ -239,11 +232,7 @@ sudo env PATH="$PATH" \ **Mac** ```sh -serviceman add \ - --path "$PATH" \ - --name dashd \ - --force \ - -- \ +serviceman add --name 'dashd' -- \ dashd \ -usehd \ -conf="$HOME/.dashcore/dash.conf" \ diff --git a/go/README.md b/go/README.md index f3a0a5168..f1b074a67 100644 --- a/go/README.md +++ b/go/README.md @@ -80,8 +80,7 @@ webi serviceman pushd ./hello/ # swap 'hello' and './hello' for the name of your project and binary -sudo env PATH="$PATH" \ - serviceman add --system --username "$(whoami)" --name hello -- \ +serviceman add --name 'hello' -- \ ./hello # Restart the logging service diff --git a/golang/README.md b/golang/README.md index 1bc0e0939..934d75c72 100644 --- a/golang/README.md +++ b/golang/README.md @@ -85,8 +85,7 @@ webi serviceman pushd ./hello/ # swap 'hello' and './hello' for the name of your project and binary -sudo env PATH="$PATH" \ - serviceman add --system --username "$(whoami)" --name hello -- \ +serviceman add --name 'hello' -- \ ./hello # Restart the logging service diff --git a/node/README.md b/node/README.md index b27769733..03aabc76c 100644 --- a/node/README.md +++ b/node/README.md @@ -276,11 +276,8 @@ Node app as a Non-System (Unprivileged) Service on Mac, Windows, and Linux: ```sh pushd ./my-node-project/ -my_username="$( id -u -n )" -sudo env PATH="$PATH" \ - serviceman add --system --path "$PATH" --cap-net-bind \ - --name my-node-project --username "${my_username}" -- \ - npm run start +serviceman add --name 'my-node-project' -- \ + npm run start ``` #### ... with auto-reload in Dev @@ -288,10 +285,8 @@ sudo env PATH="$PATH" \ ```sh pushd ./my-node-project/ -sudo env PATH="$PATH" \ - serviceman add --system --path "$PATH" --cap-net-bind \ - --name my-node-project --username "$(id -u -n)" -- \ - npx -p nodemon@3 -- nodemon ./server.js +serviceman add --name 'my-node-project' -- \ + npx -p nodemon@3 -- nodemon ./server.js ``` #### View Logs & Restart diff --git a/pg/install.sh b/pg/install.sh index 5c388190a..8895a2550 100644 --- a/pg/install.sh +++ b/pg/install.sh @@ -58,17 +58,20 @@ __init_pg() { } pkg_done_message() { - # TODO show with serviceman echo " Installed $(t_pkg "$pkg_cmd_name v$WEBI_VERSION") (and $(t_pkg "psql")) to $(t_link "$(fn_sub_home "${pkg_dst_bin}")")" echo "" echo "IMPORTANT!!!" echo "" - echo "Database initialized at $POSTGRES_DATA_DIR:" - echo " postgres -D $POSTGRES_DATA_DIR -p 5432" + echo "Database initialized at:" + echo " $POSTGRES_DATA_DIR" echo "" echo "Username and password set to 'postgres':" echo " psql 'postgres://postgres:postgres@localhost:5432/postgres'" echo "" + echo "To install as a service:" + echo " serviceman add --name 'postgres' --workdir '$POSTGRES_DATA_DIR' -- \\" + echo " postgres -D '$POSTGRES_DATA_DIR' -p 5432" + echo "" } } diff --git a/postgres/README.md b/postgres/README.md index b72250390..436f8be2b 100644 --- a/postgres/README.md +++ b/postgres/README.md @@ -34,8 +34,7 @@ To enable Postgres as a Linux Service with [serviceman](../serviceman/): \ (see macOS below) ```sh -sudo env PATH="$PATH" \ - serviceman add --system --username "$(whoami)" --name 'postgres' -- \ +serviceman add --name 'postgres' --workdir ~/.local/share/postgres/var -- \ postgres -D ~/.local/share/postgres/var -p 5432 sudo systemctl restart systemd-journald @@ -119,8 +118,7 @@ curl https://webi.sh/serviceman | sh ``` ```sh -sudo env PATH="$PATH" \ - serviceman add --system --username "$(whoami)" --name 'postgres' -- \ +serviceman add --name 'postgres' --workdir ~/.local/share/postgres/var -- \ postgres -D ~/.local/share/postgres/var -p 5432 sudo systemctl restart systemd-journald @@ -185,7 +183,7 @@ sudo tail -f /var/log/postgres #### macOS ```sh -serviceman add --name 'postgres' -- \ +serviceman add --name 'postgres' --workdir ~/.local/share/postgres/var -- \ postgres -D ~/.local/share/postgres/var -p 5432 tail -f ~/.local/share/postgres/var/log/postgres.log diff --git a/postgres/install.sh b/postgres/install.sh index 6a0d46fcf..eccf1f6ee 100644 --- a/postgres/install.sh +++ b/postgres/install.sh @@ -78,17 +78,20 @@ __init_postgres() { } pkg_done_message() { - # TODO show with serviceman echo "Installed 'postgres' and 'psql' at $pkg_dst" echo "" echo "IMPORTANT!!!" echo "" - echo "Database initialized at $POSTGRES_DATA_DIR:" - echo " postgres -D $POSTGRES_DATA_DIR -p 5432" + echo "Database initialized at:" + echo " $POSTGRES_DATA_DIR" echo "" echo "Username and password set to 'postgres':" echo " psql 'postgres://postgres:postgres@localhost:5432/postgres'" echo "" + echo "To install as a service:" + echo " serviceman add --name 'postgres' --workdir '$POSTGRES_DATA_DIR' -- \\" + echo " postgres -D '$POSTGRES_DATA_DIR' -p 5432" + echo "" } }