Class: GoodJob::SystemdService
- Inherits:
-
Object
- Object
- GoodJob::SystemdService
- Defined in:
- lib/good_job/systemd_service.rb
Overview
Manages communication with systemd to notify it about the status of the GoodJob CLI. If it doesn’t look like systemd is controlling the process, SystemdService doesn’t do anything.
Class Method Summary collapse
Instance Method Summary collapse
-
#notifying? ⇒ Boolean
Indicates whether the service is actively notifying systemd’s watchdog.
-
#start ⇒ Object
Notify systemd that the process is ready.
-
#stop ⇒ Object
Notify systemd that the process is stopping and stop pinging the watchdog if currently doing so.
Class Method Details
.task_observer(_time, _output, thread_error) ⇒ Object
:nodoc:
13 14 15 16 17 18 |
# File 'lib/good_job/systemd_service.rb', line 13 def self.task_observer(_time, _output, thread_error) # :nodoc: return if !thread_error || thread_error.is_a?(Concurrent::CancelledOperationError) ActiveSupport::Notifications.instrument("systemd_watchdog_error.good_job", { error: thread_error }) GoodJob._on_thread_error(thread_error) end |
Instance Method Details
#notifying? ⇒ Boolean
Indicates whether the service is actively notifying systemd’s watchdog.
21 22 23 |
# File 'lib/good_job/systemd_service.rb', line 21 def @watchdog&.running? || false end |
#start ⇒ Object
Notify systemd that the process is ready. If the service is configured in systemd to use the watchdog, this will also start pinging the watchdog.
27 28 29 30 |
# File 'lib/good_job/systemd_service.rb', line 27 def start GoodJob::SdNotify.ready run_watchdog end |
#stop ⇒ Object
Notify systemd that the process is stopping and stop pinging the watchdog if currently doing so. If given a block, it will wait for the block to complete before stopping watchdog notifications, so systemd has a clear indication when graceful shutdown started and finished.
36 37 38 39 40 41 42 43 |
# File 'lib/good_job/systemd_service.rb', line 36 def stop GoodJob::SdNotify.stopping yield if block_given? @watchdog&.kill @watchdog&.wait_for_termination end |