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 11, 2024
1 parent 338c1e8 commit 93ae90a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 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
10 changes: 2 additions & 8 deletions lib/solid_queue/processes/runnable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def start
end

def stop
@stopped = true
wake_up
super

wake_up
@thread&.join
end

Expand All @@ -33,8 +33,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 @@ -51,10 +49,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 93ae90a

Please sign in to comment.