seomoz / qless

Queue / Pipeline Management
MIT License
294 stars 76 forks source link

Process SIGINT as SIGQUIT #256

Open a0s opened 7 years ago

a0s commented 7 years ago

Hi gays! I try to found a way to process SIGINT as SIGQUIT (i want to wait of end of current job when i pressed Ctrl-C). And the only way to do this that i found is dirty override BaseWorker#register_signal_handlers

    module Qless
      module Workers
        class BaseWorker
          def register_signal_handlers
            trap('TERM') { exit! }
            # trap('INT') { exit! }
            trap('INT') { shutdown(in_signal_handler=true) }
            safe_trap('HUP') { sighup_handler.call }
            safe_trap('QUIT') { shutdown(in_signal_handler=true) }
            begin
              trap('CONT') { unpause(in_signal_handler=true) }
              trap('USR2') { pause(in_signal_handler=true) }
            rescue ArgumentError
              warn 'Signals USR2, and/or CONT not supported.'
            end
          end
        end
      end
    end

    worker = Qless::Workers::ForkingWorker.new(reserver, num_workers: WORKERS, logger: App.logger)
    worker.run

Did I miss something?