Implement US-16 independent Linux service installation
This commit is contained in:
1 parent
b6342afdad
commit
950f67d8b7
10 files changed
+837
No files matched your search
@@ -0,0 +1,198 @@
|
||||
# US-16 — Independent Linux installation
|
||||
|
||||
The installer supports one service, a comma-separated subset, or `all`. The same
|
||||
published application executables work for colocated and distributed deployments.
|
||||
Each service retains its own process, environment file and systemd registration.
|
||||
No additional service, shared persistence, shared application library or communication
|
||||
shortcut is introduced. Application services continue communicating through the API Gateway.
|
||||
|
||||
## Supported host and prerequisites
|
||||
|
||||
Use a Linux host with Bash 4 or later, GNU core utilities/grep/sed, a running systemd
|
||||
system manager with systemd-run, and the .NET 10 ASP.NET Core runtime. Live installation
|
||||
requires root and the standard `getent`, `groupadd`, `useradd` and `id` tools. Network
|
||||
verification additionally requires curl. Building a release requires the .NET 10 SDK
|
||||
and the repository's NuGet dependencies; deployment hosts do not need the SDK/source.
|
||||
|
||||
Provision PostgreSQL for Patient/Profile and Observation separately, with independent
|
||||
database names/users and credentials matching each service's configuration. The DBs
|
||||
may be on remote hosts. Insights and Health Overview have no databases. Provision
|
||||
trusted HTTPS certificates and the externally configured accounts/service credentials
|
||||
before starting production services. The installer does not install an identity
|
||||
provider, PostgreSQL, runtime packages or certificates and does not generate accounts.
|
||||
These remain administrator-supplied prerequisites, as in the existing deployment model.
|
||||
|
||||
## Build a release
|
||||
|
||||
From the repository root:
|
||||
|
||||
```bash
|
||||
bash deploy/build-release.sh --output /tmp/healthapp-release
|
||||
# Or publish only the service(s) needed on a particular host:
|
||||
bash deploy/build-release.sh --output /tmp/healthapp-insights-release --services insights
|
||||
```
|
||||
|
||||
Output must be a new directory. Optionally set `HEALTHAPP_DOTNET` to the SDK executable.
|
||||
The release contains selected payloads under `services/`, their systemd units,
|
||||
configuration examples, installation/verification scripts and this guide. Transfer it
|
||||
to the target Linux host using your normal deployment transport. Release contents
|
||||
are trusted executable deployment input; configuration secrets are not part of it.
|
||||
|
||||
## Prepare independent configuration
|
||||
|
||||
Copy each selected `examples/NAME.env.example` to a protected administrator directory
|
||||
as `NAME.env`. Replace placeholders with actual values. Existing examples deliberately
|
||||
use remote hostnames and separate DB credentials; they are not usable credentials.
|
||||
|
||||
Service names and resulting paths:
|
||||
|
||||
| Selection name | Application | Configuration | systemd unit |
|
||||
| --- | --- | --- | --- |
|
||||
| api-gateway | ApiGateway.dll | /etc/healthapp/api-gateway.env | healthapp-api-gateway.service |
|
||||
| patient-profile | PatientProfileService.dll | /etc/healthapp/patient-profile.env | healthapp-patient-profile.service |
|
||||
| observation | ObservationService.dll | /etc/healthapp/observation.env | healthapp-observation.service |
|
||||
| insights | InsightsService.dll | /etc/healthapp/insights.env | healthapp-insights.service |
|
||||
| health-overview | HealthOverviewService.dll | /etc/healthapp/health-overview.env | healthapp-health-overview.service |
|
||||
|
||||
Supply each service's own network binding via `ASPNETCORE_URLS`, its needed endpoints,
|
||||
credentials and (where applicable) DB connection string. The gateway needs all service
|
||||
origins/keys even when their services are deployed on other machines. Other services
|
||||
need only their documented dependencies; installation does not require them locally.
|
||||
|
||||
Use distinct service credentials in both directions, matching the gateway and service
|
||||
settings described in `src/AUTHENTICATION.md`. Never reuse example placeholders.
|
||||
Keep production `ASPNETCORE_ENVIRONMENT=Production` and configure HTTPS origins,
|
||||
certificate path/password and trust chains on each host. Certificate files must be
|
||||
readable by the `healthapp` service identity. For example, externally provision files
|
||||
under `/etc/healthapp` with group `healthapp` and mode `0640`. The installer makes that
|
||||
directory root-owned with group access, and environment files root-only `0600`;
|
||||
systemd reads environment files and passes values into the relevant process.
|
||||
|
||||
`Authentication__KeyDirectory` belongs to the gateway host alone. The gateway unit's
|
||||
StateDirectory creates `/var/lib/healthapp-api-gateway`; its `keys` child is created
|
||||
by data protection. Other machines never require that directory or another service's
|
||||
local application/configuration files. Only configured network APIs cross machines.
|
||||
|
||||
For local development tests, Development permits HTTP; production still requires
|
||||
HTTPS. No deployment path/hostname is hard-coded in an application.
|
||||
|
||||
## Install selected services
|
||||
|
||||
From the transferred release directory, assuming prepared config in `/root/healthapp-config`:
|
||||
|
||||
```bash
|
||||
# One service, with dependencies running on independently configured hosts:
|
||||
sudo bash install.sh --services insights --config-dir /root/healthapp-config
|
||||
|
||||
# A subset (use this instead of the preceding command on a fresh host):
|
||||
sudo bash install.sh --services patient-profile,observation --config-dir /root/healthapp-config --migrate
|
||||
|
||||
# Complete fresh installation:
|
||||
sudo bash install.sh --services all --config-dir /root/healthapp-config --migrate --start
|
||||
```
|
||||
|
||||
`--bundle DIRECTORY` selects a release explicitly. `--dotnet /absolute/runtime/path`
|
||||
changes only ExecStart in selected units, when dotnet is not installed at `/usr/bin/dotnet`.
|
||||
The installer checks the .NET 10 ASP.NET Core runtime on a live host.
|
||||
|
||||
Installation creates the conventional `healthapp` service user/group if absent,
|
||||
copies selected independent applications to `/opt/healthapp/NAME`, copies selected
|
||||
configurations to `/etc/healthapp/NAME.env`, registers selected units under
|
||||
`/etc/systemd/system`, reloads systemd and enables only those units for boot.
|
||||
It preflights the full selection before writing files. Unselected service files,
|
||||
configuration and registrations are untouched; no service dependency/PartOf/BindsTo
|
||||
relationships are introduced between HealthApp units.
|
||||
|
||||
Default installation does not start services or modify schemas. `--migrate` explicitly
|
||||
runs the selected Patient/Profile and/or Observation application's existing migration
|
||||
mode, under its service identity/configuration, using a transient systemd unit. It
|
||||
never migrates Insights/Overview or another service's DB. `--start` explicitly starts
|
||||
the selected units after successful installation/migrations. For migrations run
|
||||
separately, use the existing published `--migrate` commands with that service's
|
||||
configuration, then start its unit.
|
||||
|
||||
Existing installation directories, env files or units cause refusal before writes.
|
||||
This is a first-install mechanism, not an upgrade/uninstall tool. It never overwrites
|
||||
existing configuration, removes persistent data or guesses how to rotate credentials.
|
||||
A live copy/migration/systemd error can leave installed files or earlier selected units
|
||||
configured; the command fails and those files/data are retained for administrator
|
||||
inspection. There is no cross-service deployment transaction or automatic rollback.
|
||||
|
||||
`--root /absolute/staging/directory` stages an offline filesystem tree without root,
|
||||
user creation, runtime checks or systemctl calls. It is for testing/image preparation,
|
||||
not a completed live installation. It refuses `--start`/`--migrate`. Provision the
|
||||
runtime, healthapp user/group, config-directory group/certificate access and gateway
|
||||
state-directory ownership on the target, then reload/enable/start the selected units.
|
||||
The paths *inside* each unit refer to the target's `/opt` and `/etc`, not to the
|
||||
staging directory. Never mistake successful staging for successful startup.
|
||||
|
||||
## Manage and verify installation
|
||||
|
||||
Each unit can be independently managed using, for example:
|
||||
|
||||
```bash
|
||||
sudo systemctl start healthapp-insights.service
|
||||
sudo systemctl stop healthapp-insights.service
|
||||
sudo systemctl restart healthapp-insights.service
|
||||
sudo journalctl -u healthapp-insights.service
|
||||
```
|
||||
|
||||
Stopping a dependency may cause application requests needing it to fail; it does not
|
||||
stop peer processes. Services need no local process-start ordering or shared memory.
|
||||
|
||||
Prepare a protected probe directory with `NAME.curl` files for each selected service.
|
||||
These are curl data configuration files (not shell scripts), containing the actual
|
||||
HTTPS URL, trusted CA and credentials appropriate for a *read-only* HTTP 200 request.
|
||||
For example, Insights can use a configured patient/period that has observation data:
|
||||
|
||||
```text
|
||||
url = "https://insights.example.test:5083/api/patients/PATIENT_ID/insights?from=2026-09-01&to=2026-09-10"
|
||||
header = "X-Gateway-Key: ACTUAL_INSIGHTS_GATEWAY_CREDENTIAL"
|
||||
cacert = "/etc/healthapp/trusted-ca.pem"
|
||||
```
|
||||
|
||||
Use corresponding profile GET, latest-observation GET and Overview GET probes on
|
||||
those services. For API Gateway use a bearer-authenticated Overview GET. For a
|
||||
complete installation that probe must select a prepared patient/period with profile,
|
||||
latest reading and calculated insight, thereby exercising the documented gateway
|
||||
and all four application services. Ensure representative records exist through the
|
||||
normal APIs before verification. Public guidance alone cannot verify dependencies.
|
||||
Keep probes root-only; their credentials do not belong in the release or repository.
|
||||
Do not disable certificate verification. Select test/deployment data appropriate to
|
||||
the environment rather than letting installation create patient information.
|
||||
|
||||
```bash
|
||||
sudo bash verify.sh --services all --probe-dir /root/healthapp-probes
|
||||
# Explicitly permits independently stopping/starting/restarting every selected unit:
|
||||
sudo bash verify.sh --services all --probe-dir /root/healthapp-probes --cycle
|
||||
```
|
||||
|
||||
Verification checks active units, distinct real PIDs and each configured network
|
||||
probe's HTTP 200 response. `--cycle` checks peer units stay active during each stop,
|
||||
then starts/restarts that service and probes it again. HTTP response bodies and
|
||||
credentials are suppressed. Probes fail on connection errors, unexpected status or
|
||||
an exited process. Verification fails rather than treating unavailable sources as
|
||||
missing data. Use the same mechanism on every host for a distributed deployment;
|
||||
the complete-system gateway probe checks the configured remote communication paths.
|
||||
|
||||
## Automated evidence and limits
|
||||
|
||||
`tests/Deployment.AcceptanceTests` publishes a release, installs into temporary roots,
|
||||
and launches the installed assemblies as separate OS processes against temporary,
|
||||
independent PostgreSQL databases. It covers selection, preflight failures, independent
|
||||
config files/permissions/units, standalone startup for every service, multiple/all
|
||||
processes, authenticated profile/observation/Overview workflow, per-service graceful
|
||||
stop/restart, retained data and separate persistence. There are no production service
|
||||
project references in this test project and no test authentication replacement.
|
||||
|
||||
Run with Linux, Bash, .NET 10 SDK, and `TEST_POSTGRES_CONNECTION` referencing a DB
|
||||
account allowed to create isolated test databases. `HEALTHAPP_DOTNET` may select the
|
||||
SDK/runtime executable. Ordinary acceptance tests remain available in the solution.
|
||||
|
||||
This development execution environment has no running systemd manager. Automated
|
||||
process tests therefore use direct process launch and SIGINT (the same configured
|
||||
stop signal); live systemctl registration/boot cycling and production certificates
|
||||
must be verified with the supplied verifier on a supported target Linux host. The
|
||||
suite does not claim that localhost testing alone proves a deployment on separate
|
||||
physical machines. Remote origins and independent configuration are preserved by
|
||||
installation, and the target-host gateway probe is the distributed-system check.
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
fail() { printf 'Error: %s\n' "$*" >&2; exit 1; }
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
repo_dir=$(cd -- "$script_dir/.." && pwd)
|
||||
source "$script_dir/installer/services.sh"
|
||||
requested=all
|
||||
output=
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--output) [[ $# -gt 1 ]] || fail 'Missing output directory.'; output=$2; shift 2;;
|
||||
--services) [[ $# -gt 1 ]] || fail 'Missing services.'; requested=$2; shift 2;;
|
||||
--help) printf '%s\n' 'Usage: bash deploy/build-release.sh --output NEW_DIRECTORY [--services all|api-gateway,patient-profile,observation,insights,health-overview]' 'Requires .NET 10 SDK. HEALTHAPP_DOTNET may select its executable.'; exit 0;;
|
||||
*) fail "Unknown argument: $1";;
|
||||
esac
|
||||
done
|
||||
select_services "$requested"
|
||||
[[ -n "$output" && ! -e "$output" ]] || fail 'Provide a new, non-existing output directory.'
|
||||
dotnet_command=${HEALTHAPP_DOTNET:-dotnet}
|
||||
command -v "$dotnet_command" >/dev/null || fail '.NET 10 SDK is required to build a release.'
|
||||
mkdir -p -- "$output/services" "$output/systemd" "$output/examples"
|
||||
output=$(cd -- "$output" && pwd)
|
||||
cp -- "$script_dir/installer/"*.sh "$output/"
|
||||
cp -- "$script_dir/INSTALLATION.md" "$output/"
|
||||
for service in "${selected_services[@]}"; do
|
||||
assembly=$(assembly_for "$service")
|
||||
"$dotnet_command" publish "$repo_dir/src/$assembly/$assembly.csproj" --configuration Release --output "$output/services/$service"
|
||||
cp -- "$script_dir/systemd/healthapp-$service.service" "$output/systemd/"
|
||||
cp -- "$script_dir/$service.env.example" "$output/examples/"
|
||||
done
|
||||
printf '%s\n' "${selected_services[@]}" > "$output/services.list"
|
||||
printf 'Release created: %s\n' "$output"
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
fail() { printf 'Error: %s\n' "$*" >&2; exit 1; }
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
source "$script_dir/services.sh"
|
||||
bundle=$script_dir
|
||||
requested=
|
||||
config_dir=
|
||||
target_root=/
|
||||
dotnet_path=/usr/bin/dotnet
|
||||
start=false
|
||||
migrate=false
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--bundle) [[ $# -gt 1 ]] || fail 'Missing bundle directory.'; bundle=$2; shift 2;;
|
||||
--services) [[ $# -gt 1 ]] || fail 'Missing services.'; requested=$2; shift 2;;
|
||||
--config-dir) [[ $# -gt 1 ]] || fail 'Missing configuration directory.'; config_dir=$2; shift 2;;
|
||||
--root) [[ $# -gt 1 ]] || fail 'Missing staging root.'; target_root=$2; shift 2;;
|
||||
--dotnet) [[ $# -gt 1 ]] || fail 'Missing runtime path.'; dotnet_path=$2; shift 2;;
|
||||
--start) start=true; shift;;
|
||||
--migrate) migrate=true; shift;;
|
||||
--help) printf '%s\n' 'Usage: bash install.sh --services all|NAME[,NAME] --config-dir DIRECTORY [--bundle DIRECTORY] [--dotnet /absolute/path] [--migrate] [--start]' 'Optional --root DIRECTORY stages an offline filesystem image; it does not start or verify services.' 'Names: api-gateway,patient-profile,observation,insights,health-overview' 'Existing installations/configuration are never overwritten. Databases and certificates must be provisioned externally.'; exit 0;;
|
||||
*) fail "Unknown argument: $1";;
|
||||
esac
|
||||
done
|
||||
[[ $(uname -s) == Linux ]] || fail 'Only Linux is supported.'
|
||||
select_services "$requested"
|
||||
[[ -d "$bundle" && -d "$config_dir" ]] || fail 'Bundle and prepared configuration directories are required.'
|
||||
[[ "$target_root" == /* && "$target_root" != *$'\n'* && "$target_root" != *'/../'* && "$target_root" != */.. ]] || fail 'Root must be an absolute filesystem path without parent traversal.'
|
||||
[[ "$dotnet_path" =~ ^/[A-Za-z0-9_./+-]+$ ]] || fail 'Runtime must be an absolute path using letters, digits, slash, dot, underscore, plus or hyphen.'
|
||||
target_root=$(realpath -m -- "$target_root")
|
||||
if [[ "$target_root" != / ]]; then
|
||||
[[ "$start" == false && "$migrate" == false ]] || fail 'Cannot start services or migrate databases in an offline staging root.'
|
||||
else
|
||||
[[ $EUID -eq 0 ]] || fail 'Live system installation requires root.'
|
||||
[[ -d /run/systemd/system ]] || fail 'A running systemd system manager is required.'
|
||||
[[ -x "$dotnet_path" ]] || fail 'Install the .NET 10 ASP.NET Core runtime first.'
|
||||
runtime_list=$("$dotnet_path" --list-runtimes)
|
||||
[[ "$runtime_list" == *'Microsoft.AspNetCore.App 10.'* ]] || fail 'The .NET 10 ASP.NET Core runtime is required.'
|
||||
fi
|
||||
# Preflight all selected services before copying anything or registering units.
|
||||
for service in "${selected_services[@]}"; do
|
||||
assembly=$(assembly_for "$service")
|
||||
[[ -f "$bundle/services/$service/$assembly.dll" && -f "$bundle/services/$service/$assembly.runtimeconfig.json" && -f "$bundle/services/$service/$assembly.deps.json" ]] || fail "Missing published application: $service"
|
||||
[[ -f "$bundle/systemd/healthapp-$service.service" && -f "$config_dir/$service.env" ]] || fail "Missing unit or prepared configuration: $service"
|
||||
[[ ! -e "$target_root/opt/healthapp/$service" && ! -e "$target_root/etc/healthapp/$service.env" && ! -e "$target_root/etc/systemd/system/healthapp-$service.service" ]] || fail "Already installed or configured: $service. Existing files were not changed."
|
||||
if grep -q 'REPLACE_ME\|REPLACE_WITH' "$config_dir/$service.env"; then fail "Replace example configuration placeholders for $service."; fi
|
||||
done
|
||||
if [[ "$target_root" == / ]]; then
|
||||
getent group healthapp >/dev/null || groupadd --system healthapp
|
||||
id healthapp >/dev/null 2>&1 || useradd --system --gid healthapp --home-dir /nonexistent --shell /usr/sbin/nologin healthapp
|
||||
fi
|
||||
install -d -m 0755 -- "$target_root/opt/healthapp" "$target_root/etc/systemd/system"
|
||||
install -d -m 0750 -- "$target_root/etc/healthapp"
|
||||
if [[ "$target_root" == / ]]; then chgrp healthapp -- "$target_root/etc/healthapp"; fi
|
||||
for service in "${selected_services[@]}"; do
|
||||
install -d -m 0755 -- "$target_root/opt/healthapp/$service"
|
||||
cp -R -- "$bundle/services/$service/." "$target_root/opt/healthapp/$service/"
|
||||
chmod -R a+rX,go-w -- "$target_root/opt/healthapp/$service"
|
||||
install -m 0600 -- "$config_dir/$service.env" "$target_root/etc/healthapp/$service.env"
|
||||
sed "s|ExecStart=/usr/bin/dotnet |ExecStart=$dotnet_path |" "$bundle/systemd/healthapp-$service.service" > "$target_root/etc/systemd/system/healthapp-$service.service"
|
||||
chmod 0644 -- "$target_root/etc/systemd/system/healthapp-$service.service"
|
||||
printf 'Installed %s\n' "$service"
|
||||
done
|
||||
if [[ "$target_root" == / ]]; then
|
||||
systemctl daemon-reload
|
||||
if [[ "$migrate" == true ]]; then
|
||||
for service in "${selected_services[@]}"; do
|
||||
case "$service" in patient-profile|observation)
|
||||
assembly=$(assembly_for "$service")
|
||||
systemd-run --quiet --wait --pipe --collect --unit="healthapp-$service-migrate" \
|
||||
--property=User=healthapp --property=Group=healthapp \
|
||||
--property="EnvironmentFile=/etc/healthapp/$service.env" \
|
||||
--property="WorkingDirectory=/opt/healthapp/$service" \
|
||||
"$dotnet_path" "/opt/healthapp/$service/$assembly.dll" --migrate
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
for service in "${selected_services[@]}"; do
|
||||
systemctl enable "healthapp-$service.service"
|
||||
if [[ "$start" == true ]]; then systemctl start "healthapp-$service.service"; fi
|
||||
done
|
||||
printf '%s\n' 'Installation complete. Run verify.sh with the selected services and HTTP probe configuration.'
|
||||
else
|
||||
printf '%s\n' 'Offline files staged. Provision the runtime/service account and enable units on the target host before verification.'
|
||||
fi
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Deployment metadata only; each application remains independently published and configured.
|
||||
all_services=(api-gateway patient-profile observation insights health-overview)
|
||||
select_services() {
|
||||
local requested="$1" item
|
||||
selected_services=()
|
||||
if [[ "$requested" == all ]]; then
|
||||
selected_services=("${all_services[@]}")
|
||||
return
|
||||
fi
|
||||
IFS=',' read -r -a selected_services <<< "$requested"
|
||||
[[ ${#selected_services[@]} -gt 0 && "$requested" != *, ]] || fail "Select services by comma-separated name or all."
|
||||
local -A seen=()
|
||||
for item in "${selected_services[@]}"; do
|
||||
case "$item" in api-gateway|patient-profile|observation|insights|health-overview) ;; *) fail "Unknown service: $item" ;; esac
|
||||
[[ ! ${seen[$item]+exists} ]] || fail "Repeated service: $item"
|
||||
seen[$item]=1
|
||||
done
|
||||
}
|
||||
assembly_for() {
|
||||
case "$1" in
|
||||
api-gateway) printf '%s' ApiGateway;;
|
||||
patient-profile) printf '%s' PatientProfileService;;
|
||||
observation) printf '%s' ObservationService;;
|
||||
insights) printf '%s' InsightsService;;
|
||||
health-overview) printf '%s' HealthOverviewService;;
|
||||
esac
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
fail() { printf 'Error: %s\n' "$*" >&2; exit 1; }
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
source "$script_dir/services.sh"
|
||||
requested=
|
||||
probe_dir=
|
||||
cycle=false
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--services) [[ $# -gt 1 ]] || fail 'Missing services.'; requested=$2; shift 2;;
|
||||
--probe-dir) [[ $# -gt 1 ]] || fail 'Missing probe directory.'; probe_dir=$2; shift 2;;
|
||||
--cycle) cycle=true; shift;;
|
||||
--help) printf '%s\n' 'Usage: bash verify.sh --services all|NAME[,NAME] --probe-dir DIRECTORY [--cycle]' 'Each NAME.curl contains curl configuration for a configured HTTPS endpoint and the required credentials.' 'Probes must return HTTP 200 (no redirects). --cycle explicitly permits stop/start/restart of each selected service.'; exit 0;;
|
||||
*) fail "Unknown argument: $1";;
|
||||
esac
|
||||
done
|
||||
select_services "$requested"
|
||||
[[ -d "$probe_dir" ]] || fail 'Provide service-specific curl probe configuration.'
|
||||
command -v curl >/dev/null || fail 'curl is required for network verification.'
|
||||
[[ -d /run/systemd/system ]] || fail 'Verification requires a running systemd system manager.'
|
||||
for service in "${selected_services[@]}"; do
|
||||
[[ -f "$probe_dir/$service.curl" ]] || fail "Missing probe configuration: $service"
|
||||
done
|
||||
pids=()
|
||||
for service in "${selected_services[@]}"; do
|
||||
unit="healthapp-$service.service"
|
||||
systemctl is-active --quiet "$unit" || fail "$service is not active."
|
||||
pid=$(systemctl show --property MainPID --value "$unit")
|
||||
[[ "$pid" =~ ^[1-9][0-9]*$ && -d "/proc/$pid" ]] || fail "$service has no running process."
|
||||
for other in "${pids[@]}"; do [[ "$pid" != "$other" ]] || fail 'Services share a process.'; done
|
||||
pids+=("$pid")
|
||||
if [[ "$cycle" == true ]]; then
|
||||
# Confirm stopping this service does not directly stop another selected unit.
|
||||
systemctl stop "$unit"
|
||||
systemctl is-active --quiet "$unit" && fail "$service did not stop."
|
||||
for peer in "${selected_services[@]}"; do
|
||||
[[ "$peer" == "$service" ]] || systemctl is-active --quiet "healthapp-$peer.service" || fail "Stopping $service stopped $peer."
|
||||
done
|
||||
systemctl start "$unit"
|
||||
systemctl restart "$unit"
|
||||
systemctl is-active --quiet "$unit" || fail "$service did not restart."
|
||||
fi
|
||||
# curl settings are data, not sourced shell code; suppress bodies and credentials.
|
||||
status=$(curl --config "$probe_dir/$service.curl" --silent --output /dev/null --write-out '%{http_code}' --max-time 15 --max-redirs 0 --retry 5 --retry-delay 1 --retry-connrefused) || fail "Network probe failed for $service."
|
||||
[[ "$status" == 200 ]] || fail "Unexpected HTTP status for $service: $status"
|
||||
systemctl is-active --quiet "$unit" || fail "$service exited during its network probe."
|
||||
printf 'Verified process and configured network probe: %s\n' "$service"
|
||||
done
|
||||
printf '%s\n' 'Verification passed. For a complete system also run the representative API workflow documented in INSTALLATION.md.'
|
||||
Reference in new issue
Block a user