Skip to content

Commit

Permalink
Move #stop and #stopped? to Processes:Base
Browse files Browse the repository at this point in the history
As these are all common between all processes.
  • Loading branch information
rosa committed Sep 9, 2024
1 parent 1b25a07 commit 73df529
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
9 changes: 9 additions & 0 deletions lib/solid_queue/processes/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Base

def initialize(*)
@name = generate_name
@stopped = false
end

def kind
Expand All @@ -28,10 +29,18 @@ def metadata
{}
end

def stop
@stopped = true
end

private
def generate_name
[ kind.downcase, SecureRandom.hex(10) ].join("-")
end

def stopped?
@stopped
end
end
end
end
8 changes: 1 addition & 7 deletions lib/solid_queue/processes/runnable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def start
end

def stop
@stopped = true
super
@thread&.join
end

Expand All @@ -31,8 +31,6 @@ def mode
def boot
SolidQueue.instrument(:start_process, process: self) do
run_callbacks(:boot) do
@stopped = false

if running_as_fork?
register_signal_handlers
set_procline
Expand All @@ -49,10 +47,6 @@ def run
raise NotImplementedError
end

def stopped?
@stopped
end

def finished?
running_inline? && all_work_completed?
end
Expand Down
9 changes: 3 additions & 6 deletions lib/solid_queue/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ def start
run_start_hooks

start_processes

launch_heartbeat
launch_maintenance_task

supervise
end

def stop
@stopped = true
super
run_stop_hooks
end

Expand All @@ -47,7 +49,6 @@ def stop
def boot
SolidQueue.instrument(:start_process, process: self) do
run_callbacks(:boot) do
@stopped = false
sync_std_streams
end
end
Expand Down Expand Up @@ -87,10 +88,6 @@ def start_process(configured_process)
forks[pid] = process_instance
end

def stopped?
@stopped
end

def set_procline
procline "supervising #{supervised_processes.join(", ")}"
end
Expand Down

0 comments on commit 73df529

Please sign in to comment.