Skip to content

[phased-restart] add support for systemd type notify #2572

@josef-krabath

Description

@josef-krabath

The PR #2438 added support for systemd services of type notify.

# lib/puma/systemd.rb
module Puma
  class Systemd
    ...
    
    def hook_events
      @events.on_booted { SdNotify.ready }
      @events.on_stopped { SdNotify.stopping }
      @events.on_restart { SdNotify.reloading }
    end
    
    ...
  end
end

The Problem:
The systemd status gets updated as expected when performing a hot restart.
But the status stays active when performing a phased restart.
In the current implementation, SdNotify.reloading is never called during a phased restart.

A Common Scenario:
If we perform a phased restart, Puma terminates an old worker and starts a new one.
And if Puma is not able to boot up a new worker for some reason, it keeps trying.

In this case, the systemd status shouldn't stay active.
During a phased restart the status should be reloading.

Additional Context:
We monitor the status of all our systemd processes.
If the status of a process is not active any more (for a certain period of time), we get notified.

It would be awesome to keep this monitoring approach for Puma as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions