Skip to content

feat: keep server alive#4

Merged
PabloZaiden merged 1 commit intomainfrom
keep-server-alive
Feb 9, 2026
Merged

feat: keep server alive#4
PabloZaiden merged 1 commit intomainfrom
keep-server-alive

Conversation

@PabloZaiden
Copy link
Owner

@PabloZaiden PabloZaiden commented Feb 9, 2026

Closes #2

This pull request introduces a robust process monitoring and auto-restart mechanism for the opencode-server.sh script, ensuring that both the OpenCode server and its Caddy proxy are automatically relaunched if they unexpectedly die. It also adds comprehensive tests to verify the monitor’s behavior and updates the workflow to run tests on pull requests. The changes improve reliability, support graceful shutdowns, and ensure no orphaned processes remain between runs.

Process monitoring and reliability improvements:

  • Added a background monitor process in opencode-server.sh that checks the health of the OpenCode and Caddy processes, automatically relaunching them if they die unexpectedly. The monitor uses a configurable interval (OPENCODE_MONITOR_INTERVAL) and writes its PID to the PID file. It respects a stop flag for intentional shutdowns. [1] [2] [3] [4] [5]
  • Enhanced cleanup logic to terminate any orphaned processes from previous runs and remove stale PID and stop flag files before starting a new server instance.

Graceful shutdown and process management:

  • Modified the stop logic to set a stop flag and ensure the monitor process is also terminated cleanly, preventing unwanted restarts during intentional shutdowns.

Testing improvements:

  • Expanded tests/test-devcontainer.sh with new tests to verify that the monitor process is terminated on stop, and that both the OpenCode and Caddy processes are relaunched if killed externally. Also added tests to ensure processes are not relaunched after a proper stop. [1] [2]

Continuous integration:

  • Added a GitHub Actions workflow (.github/workflows/test.yml) to automatically run the test suite on pull requests targeting the main branch.

@PabloZaiden PabloZaiden merged commit 389a6c2 into main Feb 9, 2026
1 check passed
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.

Keep the opencode server running

1 participant