Skip to content

Commit d67a99b

Browse files
committed
Fixing issues with domains
1 parent 8e4a616 commit d67a99b

9 files changed

Lines changed: 171 additions & 25 deletions

File tree

ARCHITECTURE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ This document describes the high‑level architecture of /dev/push, how the main
3232
- `scripts/`: Helper scripts for local (macOS) and production environments
3333
- `compose/`: Container orchestration with Docker Compose. Files: `base.yml`, `override.yml`, `override.dev.yml`, and SSL provider-specific files (`ssl-default.yml`, `ssl-cloudflare.yml`, etc.).
3434

35+
Operational script notes:
36+
- `start.sh`, `stop.sh`, and `restart.sh` support component-scoped operations via `--components <csv>`.
37+
- `update.sh` defaults to updating `app` only; use `--all`, `--components`, `--full`, or `scripts/upgrades/*.json` metadata to widen update scope.
38+
3539
## System Diagram
3640

3741
```mermaid

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ See `registry/README.md` for the catalog format and override rules.
8282

8383
**Key scripts**:
8484

85-
- `./scripts/start.sh` / `stop.sh` / `restart.sh` — manage the stack
85+
- `./scripts/start.sh` / `stop.sh` / `restart.sh` — manage the full stack or selected components (`--components <csv>`)
8686
- `./scripts/compose.sh logs -f app` — view logs
8787
- `./scripts/db-generate.sh` — create database migration
8888
- `./scripts/clean.sh` — remove all Docker resources and data
89+
- `./scripts/update.sh` — update by ref (defaults to `app` only; use `--all` / `--components` / `--full` to expand scope)
8990

9091
See [ARCHITECTURE.md](ARCHITECTURE.md) for codebase structure.
9192

@@ -99,13 +100,13 @@ See [ARCHITECTURE.md](ARCHITECTURE.md) for codebase structure.
99100
| `scripts/db-generate.sh` | Generate Alembic migration (prompts for message) |
100101
| `scripts/db-migrate.sh` | Apply Alembic migrations (`--timeout <sec>`) |
101102
| `scripts/install.sh` | Server setup: Docker, user, clone repo, .env, systemd (`--repo <url>`, `--ref <ref>`, `--yes`, `--no-telemetry`, `--verbose`) |
102-
| `scripts/restart.sh` | Restart services (`--no-migrate`) |
103+
| `scripts/restart.sh` | Restart services (`--components <csv>`, `--no-migrate`) |
103104
| `scripts/restore.sh` | Restore from backup archive (`--archive <file>`, `--no-db`, `--no-data`, `--no-code`, `--no-restart`, `--no-backup`, `--remove-runners`, `--timeout <sec>`, `--yes`, `--verbose`) |
104-
| `scripts/start.sh` | Start stack (`--no-migrate`, `--timeout <sec>`, `--verbose`) |
105+
| `scripts/start.sh` | Start stack (`--components <csv>`, `--no-migrate`, `--timeout <sec>`, `--verbose`) |
105106
| `scripts/status.sh` | Show stack status |
106-
| `scripts/stop.sh` | Stop services (`--hard`) |
107+
| `scripts/stop.sh` | Stop services (`--components <csv>`, `--hard`) |
107108
| `scripts/uninstall.sh` | Uninstall from server (`--yes`, `--skip-backup`, `--no-telemetry`, `--verbose`) |
108-
| `scripts/update.sh` | Update by tag (`--ref <tag>`, `--all`, `--full`, `--components <csv>`, `--no-migrate`, `--no-telemetry`, `--yes`, `--verbose`) |
109+
| `scripts/update.sh` | Update by tag (default updates `app` only; use `--all`, `--full`, or `--components <csv>` to expand scope) (`--ref <tag>`, `--all`, `--full`, `--components <csv>`, `--no-migrate`, `--no-telemetry`, `--yes`, `--verbose`) |
109110

110111
## Environment variables
111112

scripts/restart.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ init_script_logging "restart"
99

1010
usage(){
1111
cat <<USG
12-
Usage: restart.sh [--no-migrate] [-h|--help]
12+
Usage: restart.sh [--components <csv>] [--no-migrate] [-h|--help]
1313
1414
Restart the /dev/push stack (stop + start).
1515
16+
--components <csv>
17+
Comma-separated list of services to restart (${VALID_COMPONENTS//|/, })
1618
--no-migrate Skip running database migrations after start
1719
-h, --help Show this help
1820
USG
@@ -21,8 +23,21 @@ USG
2123

2224
# Parse CLI flags
2325
run_migrations=1
26+
comps=""
2427
while [[ $# -gt 0 ]]; do
2528
case "$1" in
29+
--components)
30+
comps="$2"
31+
IFS=',' read -ra _rs_secs <<< "$comps"
32+
for comp in "${_rs_secs[@]}"; do
33+
comp="${comp// /}"
34+
[[ -z "$comp" ]] && continue
35+
if ! validate_component "$comp"; then
36+
exit 1
37+
fi
38+
done
39+
shift 2
40+
;;
2641
--no-migrate) run_migrations=0; shift ;;
2742
-h|--help) usage ;;
2843
*) err "Unknown option: $1"; usage ;;
@@ -36,11 +51,17 @@ docker info >/dev/null 2>&1 || { err "Docker not accessible. Run with sudo or ad
3651
# Check if stack is running
3752
# Restart stack
3853
printf '\n'
39-
printf "Restarting stack\n"
40-
run_cmd "${CHILD_MARK} Stopping stack" bash "$SCRIPT_DIR/stop.sh"
54+
if [[ -n "$comps" ]]; then
55+
printf "Restarting selected services\n"
56+
run_cmd "${CHILD_MARK} Stopping selected services" bash "$SCRIPT_DIR/stop.sh" --components "$comps"
57+
else
58+
printf "Restarting stack\n"
59+
run_cmd "${CHILD_MARK} Stopping stack" bash "$SCRIPT_DIR/stop.sh"
60+
fi
4161

4262
start_args=()
4363
((run_migrations==0)) && start_args+=(--no-migrate)
64+
[[ -n "$comps" ]] && start_args+=(--components "$comps")
4465
if ((${#start_args[@]})); then
4566
run_cmd "${CHILD_MARK} Starting stack" bash "$SCRIPT_DIR/start.sh" "${start_args[@]}"
4667
else
@@ -49,4 +70,8 @@ fi
4970

5071
# Success message
5172
printf '\n'
52-
printf "${GRN}Stack restarted. ✔${NC}\n"
73+
if [[ -n "$comps" ]]; then
74+
printf "${GRN}Selected services restarted. ✔${NC}\n"
75+
else
76+
printf "${GRN}Stack restarted. ✔${NC}\n"
77+
fi

scripts/start.sh

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ init_script_logging "start"
99

1010
usage(){
1111
cat <<USG
12-
Usage: start.sh [--no-migrate] [--timeout <sec>] [-v|--verbose] [-h|--help]
12+
Usage: start.sh [--components <csv>] [--no-migrate] [--timeout <sec>] [-v|--verbose] [-h|--help]
1313
1414
Start the /dev/push stack (dev or prod auto-detected).
1515
16+
--components <csv>
17+
Comma-separated list of services to start (${VALID_COMPONENTS//|/, })
1618
--no-migrate Skip running database migrations after start
1719
--timeout <sec> Max seconds to wait for app to become healthy (default: 60)
1820
-v, --verbose Enable verbose output
@@ -23,8 +25,21 @@ USG
2325

2426
run_migrations=1
2527
timeout=60
28+
comps=""
2629
while [[ $# -gt 0 ]]; do
2730
case "$1" in
31+
--components)
32+
comps="$2"
33+
IFS=',' read -ra _st_secs <<< "$comps"
34+
for comp in "${_st_secs[@]}"; do
35+
comp="${comp// /}"
36+
[[ -z "$comp" ]] && continue
37+
if ! validate_component "$comp"; then
38+
exit 1
39+
fi
40+
done
41+
shift 2
42+
;;
2843
--timeout) timeout="$2"; shift 2 ;;
2944
--no-migrate) run_migrations=0; shift ;;
3045
-v|--verbose) VERBOSE=1; shift ;;
@@ -95,18 +110,39 @@ set_compose_base
95110

96111
# Start stack
97112
printf '\n'
98-
if is_stack_running; then
113+
component_in_target() {
114+
local target="$1"
115+
[[ -z "$comps" ]] && return 0
116+
IFS=',' read -ra _target_secs <<< "$comps"
117+
for sec in "${_target_secs[@]}"; do
118+
sec="${sec// /}"
119+
[[ "$sec" == "$target" ]] && return 0
120+
done
121+
return 1
122+
}
123+
124+
if [[ -n "$comps" ]]; then
125+
IFS=',' read -ra _selected_services <<< "$comps"
126+
selected_services=()
127+
for service in "${_selected_services[@]}"; do
128+
service="${service// /}"
129+
[[ -n "$service" ]] && selected_services+=("$service")
130+
done
131+
run_cmd "Starting selected services" "${COMPOSE_BASE[@]}" up -d "${selected_services[@]}"
132+
elif is_stack_running; then
99133
run_cmd "Ensuring services are running" "${COMPOSE_BASE[@]}" up -d --remove-orphans
100134
else
101135
run_cmd "Starting services" "${COMPOSE_BASE[@]}" up -d --remove-orphans
102136
fi
103137

104138
# Wait for app container to be healthy
105-
printf '\n'
106-
run_cmd "Waiting for app to be ready" wait_for_app_health "$timeout"
139+
if component_in_target "app"; then
140+
printf '\n'
141+
run_cmd "Waiting for app to be ready" wait_for_app_health "$timeout"
142+
fi
107143

108144
# Run migrations when appropriate
109-
if ((run_migrations==1)); then
145+
if ((run_migrations==1)) && component_in_target "app"; then
110146
run_cmd "${CHILD_MARK} Running database migrations" bash "$SCRIPT_DIR/db-migrate.sh"
111147
fi
112148

scripts/stop.sh

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ init_script_logging "stop"
99

1010
usage(){
1111
cat <<USG
12-
Usage: stop.sh [--hard] [-h|--help]
12+
Usage: stop.sh [--components <csv>] [--hard] [-h|--help]
1313
1414
Stop the /dev/push stack (dev or prod auto-detected).
1515
16+
--components <csv>
17+
Comma-separated list of services to stop (${VALID_COMPONENTS//|/, })
1618
--hard Force stop all containers labeled for the devpush project
1719
-h, --help Show this help
1820
USG
@@ -57,8 +59,21 @@ force_stop_all() {
5759

5860
# Parse CLI flags
5961
hard_mode=0
62+
comps=""
6063
while [[ $# -gt 0 ]]; do
6164
case "$1" in
65+
--components)
66+
comps="$2"
67+
IFS=',' read -ra _sp_secs <<< "$comps"
68+
for comp in "${_sp_secs[@]}"; do
69+
comp="${comp// /}"
70+
[[ -z "$comp" ]] && continue
71+
if ! validate_component "$comp"; then
72+
exit 1
73+
fi
74+
done
75+
shift 2
76+
;;
6277
--hard) hard_mode=1; shift ;;
6378
-h|--help) usage ;;
6479
*) err "Unknown option: $1"; usage ;;
@@ -70,21 +85,65 @@ cd "$APP_DIR" || { err "App dir not found: $APP_DIR"; exit 1; }
7085
docker info >/dev/null 2>&1 || { err "Docker not accessible. Run with sudo or add your user to the docker group."; exit 1; }
7186

7287
if ((hard_mode==0)); then
73-
if ! is_stack_running; then
74-
printf '\n'
75-
printf "${DIM}No running services to stop.${NC}\n"
76-
exit 0
88+
if [[ -z "$comps" ]]; then
89+
if ! is_stack_running; then
90+
printf '\n'
91+
printf "${DIM}No running services to stop.${NC}\n"
92+
exit 0
93+
fi
7794
fi
7895
fi
7996

97+
service_running() {
98+
local service="$1"
99+
docker ps \
100+
--filter "label=com.docker.compose.project=devpush" \
101+
--filter "label=com.docker.compose.service=${service}" \
102+
-q \
103+
| grep -q .
104+
}
105+
106+
selected_services=()
107+
if [[ -n "$comps" ]]; then
108+
IFS=',' read -ra _selected_services <<< "$comps"
109+
for service in "${_selected_services[@]}"; do
110+
service="${service// /}"
111+
[[ -n "$service" ]] && selected_services+=("$service")
112+
done
113+
fi
114+
80115
if ((hard_mode==1)); then
81-
if ! force_stop_all; then
116+
if ((${#selected_services[@]} > 0)); then
117+
selected_ids=()
118+
for service in "${selected_services[@]}"; do
119+
while IFS= read -r cid; do
120+
[[ -n "$cid" ]] && selected_ids+=("$cid")
121+
done < <(
122+
docker ps \
123+
--filter "label=com.docker.compose.project=devpush" \
124+
--filter "label=com.docker.compose.service=${service}" \
125+
-q 2>/dev/null || true
126+
)
127+
done
128+
printf '\n'
129+
if ((${#selected_ids[@]} > 0)); then
130+
run_cmd "Stopping selected containers (${#selected_ids[@]} found)" docker stop "${selected_ids[@]}"
131+
else
132+
printf "Stopping selected containers (0 found) ${YEL}${NC}\n"
133+
fi
134+
elif ! force_stop_all; then
82135
exit 1
83136
fi
84137
else
85138
set_compose_base
86139
printf '\n'
87-
if ! run_cmd --try "Stopping stack..." "${COMPOSE_BASE[@]}" stop; then
140+
if ((${#selected_services[@]} > 0)); then
141+
if ! run_cmd --try "Stopping selected services..." "${COMPOSE_BASE[@]}" stop "${selected_services[@]}"; then
142+
printf '\n'
143+
err "Graceful stop failed for selected services."
144+
exit 1
145+
fi
146+
elif ! run_cmd --try "Stopping stack..." "${COMPOSE_BASE[@]}" stop; then
88147
printf '\n'
89148
err "Graceful stop failed; force-stopping containers."
90149
if ! force_stop_all; then
@@ -99,7 +158,21 @@ if ! docker ps --filter "label=com.docker.compose.project=devpush" >/dev/null 2>
99158
err "Unable to verify whether containers are stopped (docker ps failed)."
100159
exit 1
101160
fi
102-
if is_stack_running; then
161+
if ((${#selected_services[@]} > 0)); then
162+
running_selected=0
163+
for service in "${selected_services[@]}"; do
164+
if service_running "$service"; then
165+
running_selected=1
166+
break
167+
fi
168+
done
169+
if ((running_selected==1)); then
170+
printf '\n'
171+
err "Some selected services are still running."
172+
err "Try: scripts/stop.sh --components ${comps} --hard (or run with sudo)."
173+
exit 1
174+
fi
175+
elif is_stack_running; then
103176
printf '\n'
104177
err "Stack still has running containers."
105178
err "Try: scripts/stop.sh --hard (or run with sudo)."

scripts/update-apply.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Usage: update-apply.sh [--ref <tag>] [--all | --components <csv> | --full] [--no
1616
Apply a fetched update: validate, pull images, rollout, migrate, and record version.
1717
1818
--ref <tag> Git tag to record (best-effort if omitted)
19+
Default update scope is app only unless overridden by flags or upgrade metadata
1920
--all Update app and workers (app,worker-jobs,worker-monitor)
2021
--components <csv>
2122
Comma-separated list of services to update (${VALID_COMPONENTS//|/, })
@@ -106,7 +107,7 @@ ver_lte() {
106107
}
107108

108109
# Versioned file helper
109-
default_components="app,worker-jobs,worker-monitor"
110+
default_components="app"
110111
meta_full=0
111112
meta_components=""
112113
meta_reason=""
@@ -298,7 +299,7 @@ if ((do_full==1)); then
298299
full_update
299300
fi
300301

301-
# Option2: Components update (no downtime for app and workers)
302+
# Option2: Components update
302303
if ((do_full==0)); then
303304
if [[ -z "$comps" ]]; then
304305
if ((do_all==1)); then
@@ -315,7 +316,7 @@ if ((do_full==0)); then
315316
if [[ -n "$meta_reason" ]]; then
316317
printf "${YEL}Update reason: %s${NC}\n" "$meta_reason"
317318
fi
318-
printf "${YEL}This will update and blue-green restart: %s${NC}\n" "${comps//,/ }"
319+
printf "${YEL}This will update and restart components: %s${NC}\n" "${comps//,/ }"
319320
if [[ ! -t 0 ]]; then
320321
err "Non-interactive mode: pass --yes to proceed with component update"
321322
exit 1

scripts/update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Usage: update.sh [--ref <tag>] [--all | --components <csv> | --full] [--no-migra
2121
Update /dev/push by Git tag; performs rollouts (blue-green rollouts or simple restarts).
2222
2323
--ref <tag> Git tag to update to (default: latest stable tag)
24+
Default update scope is app only unless overridden by flags or upgrade metadata
2425
--all Update app and workers (app,worker-jobs,worker-monitor)
2526
--components <csv>
2627
Comma-separated list of services (${VALID_COMPONENTS//|/, })

scripts/upgrades/0.4.6.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"components": "app,traefik",
3+
"reason": "Reload Traefik static config for custom-domain HTTP-01 resolver (lehttp)"
4+
}

scripts/upgrades/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This directory contains versioned upgrade hooks and optional update metadata.
99
## Update Metadata
1010
- File format: `X.Y.Z.json`
1111
- Purpose: Declarative update scope defaults and user-facing reason.
12+
- Note: without metadata or CLI overrides, `update.sh` defaults to updating `app` only.
1213
- Keys:
1314
- `full` (boolean) to force a full stack update (equivalent to `--full`)
1415
- `components` (string) to default to a component set

0 commit comments

Comments
 (0)