Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Worker skeleton
class TestWorker
def startup
# Change process name
$PROGRAM_NAME = "HL7 - noop working..."
# Create pid file
File.open("tmp/pids/workers.pid", "a") {|f| f.puts Process.pid }
# Go daemon and disconnect from STDOUT/STDERR
Process.daemon(true)
# Trap signal to stop process gracefully
@stop = false
["TERM", "USR1", "HUP", "USR2"].each do |signal|
Signal.trap(signal){ @stop = true }
end
end
def work
startup
until @stop
# Do the work
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.