Skip to content

feat(deploy): support systemd --user process manager for nextjs-ssr - #42

Open
keypair34 wants to merge 1 commit into
developmentfrom
feature/pm2-to-systemd
Open

feat(deploy): support systemd --user process manager for nextjs-ssr#42
keypair34 wants to merge 1 commit into
developmentfrom
feature/pm2-to-systemd

Conversation

@keypair34

Copy link
Copy Markdown
Collaborator

Add an optional process_manager field to the nextjs-ssr deploy config. When set to "systemd", the deploy restarts the app via a git-owned systemctl --user restart <pm2_app>.service (no sudo, XDG_RUNTIME_DIR set, aborts if the unit is missing) instead of pm2. Default/"pm2" is unchanged.

This replaces the pm2 daemon model that could leave an orphaned next-server holding the port after a restart (the karokowe.com gateway-timeout outage); a systemd --user unit is cgroup-supervised so restart reaps the whole tree, and linger makes it boot-persistent with no pm2 save.

  • model: process_manager: Option on DeployConfig and Project
  • config: merge deploy_config.process_manager into project
  • deploy: restart_stanza() helper branches pm2 vs systemd, injected into the deploy script; unit tests for both branches
  • docs: smbcloud-deploy-nextjs skill "Process manager: systemd --user"

Related Issue

Fixes #

Description

Type of Change

  • Bug fix
  • New feature
  • Refactor (no functional change)
  • Documentation update
  • CI / tooling change

How Has This Been Tested?

  • cargo test --all-features
  • Manual testing (smb <command>)

Checklist

  • cargo check --workspace passes
  • cargo clippy --workspace --tests -- -D warnings passes
  • cargo fmt --all -- --check passes
  • No new unwrap() or expect() calls in production code
  • No new mod.rs files introduced
  • New dependencies added to root Cargo.toml and inherited with { workspace = true }
  • Error messages are user-friendly and surfaced to the terminal

Release Notes

Add an optional `process_manager` field to the nextjs-ssr deploy config.
When set to "systemd", the deploy restarts the app via a git-owned
`systemctl --user restart <pm2_app>.service` (no sudo, XDG_RUNTIME_DIR set,
aborts if the unit is missing) instead of pm2. Default/"pm2" is unchanged.

This replaces the pm2 daemon model that could leave an orphaned next-server
holding the port after a restart (the karokowe.com gateway-timeout outage);
a systemd --user unit is cgroup-supervised so restart reaps the whole tree,
and linger makes it boot-persistent with no `pm2 save`.

- model: process_manager: Option<String> on DeployConfig and Project
- config: merge deploy_config.process_manager into project
- deploy: restart_stanza() helper branches pm2 vs systemd, injected into
  the deploy script; unit tests for both branches
- docs: smbcloud-deploy-nextjs skill "Process manager: systemd --user"

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant