Skip to content

Run the Gateway under a lightweight supervisor - #184

Closed
awheeler294 wants to merge 2 commits into
masterfrom
gateway-restart-supervisor
Closed

awheeler294 wants to merge 2 commits into
masterfrom
gateway-restart-supervisor

Conversation

@awheeler294

Copy link
Copy Markdown
Contributor

Summary

Part of the work to allow the Gateway to restart itself.

This PR covers 2 commits. The first is a small refactor to allow AppOptions to be used publicly, so the launch decision logic can be self contained. The second commit adds the Supervisor module and functionality.

For an ordinary launch, the gateway now starts a supervisor function that runs the serving gateway as a child process. The supervisor will be able to read the child's exit code and restart it upon request (not implemented yet).

Code Changes

Adds crates/gateway/app/src/supervisor.rs module. It has a single public function run, which manages the child gateway processes lifecycle from birth to death. Run takes and holds the launch lock while it's running, so any other launch attempts will attach to it's wrapped gateway. Launch args are passed through and the child's output is passed
out to the supervisor, so the whole thing is transparent to the end user.

Makes some changes to crates/gateway-api-discovery. This is the public interface between the gateway and the rest of Runvil.
launch_or_attachand launch_or_attach_cancellable become LaunchDecision::decide_launch and LaunchDecision::decide_launch_cancellable to better reflect that they are returning the results of a decision, and not
doing anything else. They're semantics are unchanged, this is a purely syntactic change.
settle_gateway_startup now takes an AppOptions instead of a ServeOptions. AppOptions contains a ServeOptions, this just allows the function to examine the full AppOptions.

External changes

The changes to launch_or_attach_cancellable require some minor changes to Workshop.

User Facing Changes

Aside from the minor API changes in gateway-api-discovery there are no user facing changes in this commit.

Move `AppOptions` and `LaunchCommand` from cli.rs to runner.rs so they
can be used by code under `lib.rs`.

Note: We need to make a lib directory so it's more obvios which code is
in lib's source tree vs main's.
- Summary
Part of the work to allow the Gateway to restart itself. For an ordinary
launch, the gateway starts a supervisor function that runs the serving
gateway as a child process. The supervisor will be able to read the
child's exit code and restart it upon request (not implemented yet).

- Code Changes
Adds `crates/gateway/app/src/supervisor.rs` module. It has a single
public function `run`, which manages the child gateway processes
lifecycle from birth to death. Run takes and holds the launch lock while
it's running, so any other launch attempts will attach to it's wrapped
gateway. Launch args are passed through and the child's output is passed
out to the supervisor, so the whole thing is transparent to the end
user.

Makes some changes to `crates/gateway-api-discovery`. This is the public
interface between the gateway and the rest of Runvil.
`launch_or_attach`and `launch_or_attach_cancellable` become
`LaunchDecision::decide_launch` and `LaunchDecision::decide_launch_cancellable`
to better reflect that they are returning the results of a decision, and not
doing anything else. They're semantics are unchanged, this is a purely syntactic
change.
`settle_gateway_startup` now takes an `AppOptions` instead of a
`ServeOptions`. `AppOptions` contains a `ServeOptions`, this just
allows the function to examine the full `AppOptions`.

- External changes
The changes to `launch_or_attach_cancellable` require some minor changes
to Workshop.

- User Facing Changes
Aside from the minor API changes in `gateway-api-discovery` there are no
user facing changes in this commit.
@vinniefalco

Copy link
Copy Markdown
Member

Deleting the branch behind this pull request; the work can be recovered from commit 0e37dc7 if it is ever wanted.

@vinniefalco
vinniefalco deleted the gateway-restart-supervisor branch October 31, 2026 02:02
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.

2 participants