doc(serviceman): update docs across installers

This commit is contained in:
AJ ONeal
2024-12-12 00:45:11 +00:00
parent e2ad197067
commit 40316a866c
12 changed files with 54 additions and 90 deletions

View File

@@ -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/ \

View File

@@ -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 "$(id -u -n)" --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
```

View File

@@ -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: <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

View File

@@ -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" \

View File

@@ -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 \

View File

@@ -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" \

View File

@@ -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 "$(id -u -n)" --name hello -- \
serviceman add --name 'hello' -- \
./hello
# Restart the logging service

View File

@@ -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 "$(id -u -n)" --name hello -- \
serviceman add --name 'hello' -- \
./hello
# Restart the logging service

View File

@@ -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

View File

@@ -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 ""
}
}

View File

@@ -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 "$(id -u -n)" --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 "$(id -u -n)" --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

View File

@@ -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 ""
}
}