cloudflare / cloudflare/pingora

Support running `Server` without `std::process::exit`

Open
#492 0 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
27.4k
Forks
1.7k
Avg merge
6h 22m
Merged PRs (30d)
3

Description

## Problem

Pingora server code assumes it won't be wrapped by something else since the only entry point `Server::run_forever` which calls `std::process::exit(0)`.

## Solution

Refactor `Server` so that an additional run function can be called that returns with `Result` instead of exiting the process. It would be up to the caller to support daemonization or not. I'd assume the daemonization and shutdown signal generation code could be refactored out so that a pingora wrapper could use them as needed.

Basically, would be nice to see code similar to how `axum` can be run:

```rust
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal())
.await
```

## Alternatives

- Fork/exec from wrapper (whether Rust or not)
- Advantages:
- Can sandbox pingora (if OS supports)
- If separate binary, options other than pingora are possible
- Disadvantages:
- Would require setting up IPC or RPC to control the proxy instead something else like a FFI binding

## Additional context

Planning to supporting features like #374 may influence the overall design.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.