cloudflare/pingora

Shutdown behavior question

Closed this issue · 5 comments

I was surprised to see that Pingora seems to require that it fully control the lifecycle of the process it runs in. For example, run_forever(...) literally expects to run forever and can only be influenced via OS signals (e.g. SIGINT). Then there is the curious behavior of forcing a process exit after any of SIGINT, SIGQUIT, and SIGTERM.

If I wanted to handle destroying and recreating a pingora server within my process for faster reloads or any other reason (e.g. integrating with an existing system that requires something different), I am not able to.

I couldn't see any reason why Pingora would require these behaviors other than they seemed like a reasonable sane starting point. Would the project be open to a contribution that allows for more control by the entity that instantiates the Pingora Server? For example, a change to run_forever or alternative to run_forever that supports an application level "stop" signal that does not result in process exit.

Although maybe this is already in the process of changing in an upcoming release based on what I see in https://github.com/cloudflare/pingora/blob/main/pingora-core/src/server/mod.rs#L388

@avirtuos i have solution, dont use run forever. use normal run with default args, and use crate ctrlc to handle the sigint, and use atomic mark for marking which is active or not, i have implemented this programatically (app level).

if you interested you can take a look at my configration

  • main.rs for handling the ctrlc and use ctrl+x to gracefully exit program
  • server.rs the pingora implementation

hope this helps.

@zonblade Thanks for the reply. That is certainly a useful example. If I understand what you linked correctly, you are not using an official Pingora release but rather some snapshot of Pingora from ~2 months ago. Is that correct? I can see they made more than a few changes since the previous release that would make this much easier. I didn't get to see if your example depends on those changes or is viable even using the prior release 0.4.

@zonblade Thanks for the reply. That is certainly a useful example. If I understand what you linked correctly, you are not using an official Pingora release but rather some snapshot of Pingora from ~2 months ago. Is that correct? I can see they made more than a few changes since the previous release that would make this much easier. I didn't get to see if your example depends on those changes or is viable even using the prior release 0.4.

@avirtuos it is my main branch, i have the development branch wich using latest Pingora. it is work with latest Pingora release or Pingora main too. you can take a look here main.rs and server.rs for my latest update

also yes i use snapshots (fork) from Pingora for some experimental reason.

the concept remain the same

This question has been stale for a week. It will be closed in an additional day if not updated.

This issue has been closed because it has been stalled with no activity.