Skip to content

Instantly share code, notes, and snippets.

@bradland
Created September 6, 2012 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradland/3658917 to your computer and use it in GitHub Desktop.
Save bradland/3658917 to your computer and use it in GitHub Desktop.
module MyApps
# The MyApps module illustrates a common
# The first app class includes a call to Signal::trap
class App1
def initialize
@pid = Process.pid
end
def run
puts "Running with process ID: #{@pid}"
loop do
sleep 1
STDERR.puts "[#{@pid}]: Still running"
end
end
trap(:INT) { STDERR.puts "\nSIGINT received. Exiting!"; exit 0 }
end
# This is the app class that we will run
class App2
def initialize
@pid = Process.pid
end
def run
puts "Running with process ID: #{@pid}"
loop do
sleep 1
STDERR.puts "[#{@pid}]: Still running"
end
end
end
end
MyApps::App2.new.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment