module Pakyow::Behavior::Running
Public Instance Methods
process(name, count: 1, restartable: true, &block)
click to toggle source
# File lib/pakyow/behavior/running.rb, line 68 def process(name, count: 1, restartable: true, &block) @processes << { name: name, block: block, count: count.to_i, restartable: restartable } end
restart()
click to toggle source
# File lib/pakyow/behavior/running.rb, line 122 def restart @process_manager.restart end
run()
click to toggle source
# File lib/pakyow/behavior/running.rb, line 77 def run performing :run do @process_manager = @processes.each_with_object(ProcessManager.new) { |process, manager| manager.add(process) } root_pid = Process.pid at_exit do if Process.pid == root_pid shutdown else @apps.select { |app| app.respond_to?(:shutdown) }.each(&:shutdown) end end end @process_manager.wait if @respawn # Replace the master process with a copy of itself. # exec "PW_RESPAWN=true #{$0} #{ARGV.join(" ")}" end rescue SignalException, Interrupt exit end
shutdown()
click to toggle source
# File lib/pakyow/behavior/running.rb, line 107 def shutdown if $stdout.isatty # Don't let ^C mess up our output. # puts end Pakyow.logger << "Goodbye" performing :shutdown do @bound_endpoint.close @process_manager.stop end end