Skip to content

Commit

Permalink
doc(serviceman): update docs across installers
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Dec 12, 2024
1 parent feb115f commit f0736b3
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 90 deletions.
4 changes: 2 additions & 2 deletions brew/brew-update-service-install
Original file line number Diff line number Diff line change
Expand Up @@ -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/ \
Expand Down
6 changes: 2 additions & 4 deletions bun/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
37 changes: 15 additions & 22 deletions caddy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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`:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1363,19 +1362,13 @@ See also: <https://caddyserver.com/docs/running>
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
Expand Down
3 changes: 1 addition & 2 deletions dashcore-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
34 changes: 11 additions & 23 deletions dashcore-utils/dashd-hd-service-install
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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/"
Expand All @@ -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 \
Expand Down
15 changes: 2 additions & 13 deletions dashd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -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" \
Expand Down
3 changes: 1 addition & 2 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions golang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,22 +276,17 @@ 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
```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
Expand Down
9 changes: 6 additions & 3 deletions pg/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}
}

Expand Down
8 changes: 3 additions & 5 deletions postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions postgres/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}
}

Expand Down

0 comments on commit f0736b3

Please sign in to comment.