Class: Lambchop::WatchDog
- Inherits:
-
Object
- Object
- Lambchop::WatchDog
- Defined in:
- lib/lambchop/watch_dog.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(function_name, options = {}) ⇒ WatchDog
constructor
A new instance of WatchDog.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(function_name, options = {}) ⇒ WatchDog
Returns a new instance of WatchDog.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lambchop/watch_dog.rb', line 8 def initialize(function_name, = {}) @function_name = function_name @log_group_name = "/aws/lambda/#{@function_name}" @client = [:client] || Aws::CloudWatchLogs::Client.new @start_time = [:start_time] || Time.now @out = [:out] || $stdout @last_timestamp = (@start_time) - 1 @interval = [:interval] || 1 @options = end |
Class Method Details
.start(function_name, options = {}) ⇒ Object
4 5 6 |
# File 'lib/lambchop/watch_dog.rb', line 4 def self.start(function_name, = {}) self.new(function_name, ).start end |
Instance Method Details
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lambchop/watch_dog.rb', line 19 def start @running = true Thread.start do while @running follow_logs sleep @interval end end end |
#stop ⇒ Object
30 31 32 |
# File 'lib/lambchop/watch_dog.rb', line 30 def stop @running = false end |