lib/daemons/application_group.rb
# Specify :force_kill_wait => (seconds to wait) and this method will
# block until the process is dead.  It first sends a TERM signal, then
# a KILL signal (-9) if the process hasn't died after the wait time.
# Note: The force argument is from the original daemons implementation.
Specify :force_kill_wait => (seconds to wait) and this method will
block until the process is dead.  It first sends a TERM signal, then
a KILL signal (-9) if the process hasn't died after the wait time.
Note: The force argument is from the original daemons implementation.
Specify : force_kill_wait = > ( seconds to wait ) and this method will block until the process is dead . It first sends a TERM signal then a KILL signal ( - 9 ) if the process hasn ' t died after the wait time . Note : The force argument is from the original daemons implementation .
def stop_all(force = false)
      @monitor.stop if @monitor
      failed_to_kill = false
      debug = options[:debug]
      wait = options[:force_kill_wait].to_i
      pids = unix_pids
      if wait > 0 && pids.size > 0
        puts "[daemons_ext]: Killing #{app_name} with force after #{wait} secs."
        STDOUT.flush
        pids.each {|pid| Process.kill('TERM', pid) rescue Errno::ESRCH}
        begin
          Timeout::timeout(wait) {block_on_pids(wait, debug, options[:sleepy_time] || 1)}
        rescue Timeout::Error
          puts "[daemons_ext]: Time is up! Forcefully killing #{unix_pids.size} #{app_name}(s)..."
          STDOUT.flush
          unix_pids.each {|pid| `kill -9 #{pid}`}
          begin
            Timeout::timeout(30) {block_on_pids(wait, debug, options[:sleepy_time] || 1)}
          rescue Timeout::Error
            failed_to_kill = true
            puts "[daemons_ext]: #{unix_pids} #{app_name}(s) won't die! Giving up."
            STDOUT.flush
          end
        ensure
          @applications.each {|a| a.zap!}
        end
        puts "[daemons_ext]: All #{app_name}s dead." unless failed_to_kill
        STDOUT.flush
      else
        @applications.each {|a| 
          if force
            begin; a.stop; rescue ::Exception; end
          else
            a.stop
          end
        }
      end
    end
def stop_all ( force = false ) @monitor . stop if @monitor failed_to_kill = false debug = options [ :debug ] wait = options [ :force_kill_wait ] . to_i pids = unix_pids if wait > 0 && pids . size > 0 puts "[daemons_ext]: Killing #{app_name} with force after #{wait} secs." STDOUT . flush pids . each { | pid | Process . kill ( 'TERM' , pid ) rescue Errno :: ESRCH } begin Timeout :: timeout ( wait ) { block_on_pids ( wait , debug , options [ :sleepy_time ] || 1 ) } rescue Timeout :: Error puts "[daemons_ext]: Time is up! Forcefully killing #{unix_pids.size} #{app_name}(s)..." STDOUT . flush unix_pids . each { | pid | ` kill -9  #{ pid } ` } begin Timeout :: timeout ( 30 ) { block_on_pids ( wait , debug , options [ :sleepy_time ] || 1 ) } rescue Timeout :: Error failed_to_kill = true puts "[daemons_ext]: #{unix_pids} #{app_name}(s) won't die! Giving up." STDOUT . flush end ensure @applications . each { | a | a . zap! } end puts "[daemons_ext]: All #{app_name}s dead." unless failed_to_kill STDOUT . flush else @applications . each { | a | if force begin ; a . stop ; rescue :: Exception ; end else a . stop end } end end
Specify :force_kill_wait => (seconds to wait) and this method will
block until the process is dead.
Specify : force_kill_wait = > ( seconds to wait ) and this method will block until the process is dead .
# Send term first, don't delete PID files. # Give it an extra 30 seconds to kill -9 # Delete Pidfiles
force
<not_specific>