Skip to content

Instantly share code, notes, and snippets.

@ess
Created December 17, 2015 00:58
Show Gist options
  • Save ess/a1f8a7c21f34e5bf7bfc to your computer and use it in GitHub Desktop.
Save ess/a1f8a7c21f34e5bf7bfc to your computer and use it in GitHub Desktop.
def write_pid
if path = options[:pidfile]
pidfile = File.expand_path(path)
`logger -t sidekiq-runner "Writing #{::Process.pid} to #{pidfile}"`
File.open(pidfile, 'w') do |f|
f.puts ::Process.pid
end
sleep 1
unless File.exist?(pidfile)
`logger -t 'sidekiq-runner' "#{pidfile} no longer exists after being written"`
raise "The pidfile doesn't exist after I wrote it"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment