Created
September 6, 2012 17:46
-
-
Save bradland/3658917 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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