module Procrastinator::QueueManager::ParentMethods

Methods exclusive to the main/parent process

Public Instance Methods

check_for_name(name) click to toggle source
# File lib/procrastinator/queue_manager.rb, line 189
         def check_for_name(name)
            # better to use backticks so we can get the info and not spam user's stdout
            warn <<~WARNING unless `pgrep -f #{ name }`.empty?
               Warning: there is another process named "#{ name }". Use #each_process(prefix: '') in
                        Procrastinator setup if you want to help yourself distinguish them.
            WARNING
         end
kill_old_workers() click to toggle source
# File lib/procrastinator/queue_manager.rb, line 162
def kill_old_workers
   @config.pid_dir.mkpath

   @config.pid_dir.each_child do |file|
      pid = file.read.to_i

      begin
         Process.kill('KILL', pid)
         @logger.info("Killing old worker process pid: #{ pid }")
      rescue Errno::ESRCH
         @logger.info("Expected old worker process pid=#{ pid }, but none was found")
      end

      file.delete
   end
end
write_pid_file(pid, filename) click to toggle source
# File lib/procrastinator/queue_manager.rb, line 179
def write_pid_file(pid, filename)
   @config.pid_dir.mkpath

   pid_file = @config.pid_dir + "#{ filename }.pid"

   File.open(pid_file.to_path, 'w') do |f|
      f.print(pid)
   end
end