Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifecycle conditions are disabled on restart #151

Open
rasmuskl opened this issue Nov 1, 2013 · 0 comments
Open

Lifecycle conditions are disabled on restart #151

rasmuskl opened this issue Nov 1, 2013 · 0 comments

Comments

@rasmuskl
Copy link

rasmuskl commented Nov 1, 2013

Given a simple script like the one below - the lifecycle events will die when the job is restarted via god restart simple. This will also happen in other circumstances when other transitions are active, but this should be simple enough to reproduce it.

God.watch do |w|
  w.name = 'simple'
  w.start = 'echo "test" > /dev/null'

  w.lifecycle do |on|
    on.condition(:process_running) do |c|
      c.interval = 3.seconds
      c.running = true
    end
  end
end

Log [starting the job - lifecycle is enabled]

> sudo god --no-daemonize --log-level debug
I [2013-11-01 15:53:43]  INFO: Syslog enabled.
I [2013-11-01 15:53:43]  INFO: Using pid file directory: /var/run/god
I [2013-11-01 15:53:43]  INFO: Started on drbunix:///tmp/god.17165.sock
I [2013-11-01 15:53:55]  INFO: simple Loaded config
I [2013-11-01 15:53:55]  INFO: simple move 'unmonitored' to 'up'
D [2013-11-01 15:53:55] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 0 seconds
I [2013-11-01 15:53:55]  INFO: simple moved 'unmonitored' to 'up'
I [2013-11-01 15:53:55]  INFO: simple [ok] process is not running (ProcessRunning)
D [2013-11-01 15:53:55] DEBUG: simple ProcessRunning [false] none
D [2013-11-01 15:53:55] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 3 seconds
I [2013-11-01 15:53:58]  INFO: simple [ok] process is not running (ProcessRunning)
D [2013-11-01 15:53:58] DEBUG: simple ProcessRunning [false] none
D [2013-11-01 15:53:58] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 3 seconds
I [2013-11-01 15:54:01]  INFO: simple [ok] process is not running (ProcessRunning)
D [2013-11-01 15:54:01] DEBUG: simple ProcessRunning [false] none
D [2013-11-01 15:54:01] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 3 seconds
I [2013-11-01 15:54:04]  INFO: simple [ok] process is not running (ProcessRunning)
D [2013-11-01 15:54:04] DEBUG: simple ProcessRunning [false] none
D [2013-11-01 15:54:04] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 3 seconds

Log [Stopping the job and restarting - lifecycle is reenabled]

I [2013-11-01 15:54:06]  INFO: simple stop: default lambda killer
I [2013-11-01 15:54:06]  INFO: simple sent SIGTERM
I [2013-11-01 15:54:06]  INFO: simple process stopped
I [2013-11-01 15:54:06]  INFO: simple move 'up' to 'unmonitored'
I [2013-11-01 15:54:06]  INFO: simple moved 'up' to 'unmonitored'
I [2013-11-01 15:54:11]  INFO: simple move 'unmonitored' to 'up'
D [2013-11-01 15:54:11] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 0 seconds
I [2013-11-01 15:54:11]  INFO: simple moved 'unmonitored' to 'up'
I [2013-11-01 15:54:11]  INFO: simple [ok] process is not running (ProcessRunning)
D [2013-11-01 15:54:11] DEBUG: simple ProcessRunning [false] none
D [2013-11-01 15:54:11] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 3 seconds
I [2013-11-01 15:54:14]  INFO: simple [ok] process is not running (ProcessRunning)
D [2013-11-01 15:54:14] DEBUG: simple ProcessRunning [false] none
D [2013-11-01 15:54:14] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 3 seconds

Log [restart - lifecycle dies]

I [2013-11-01 15:54:28]  INFO: simple [ok] process is not running (ProcessRunning)
D [2013-11-01 15:54:28] DEBUG: simple ProcessRunning [false] none
D [2013-11-01 15:54:28] DEBUG: driver schedule #<God::Conditions::ProcessRunning:0x007fe3e8837060> in 3 seconds
I [2013-11-01 15:54:29]  INFO: simple move 'up' to 'restart'
I [2013-11-01 15:54:29]  INFO: simple stop: default lambda killer
I [2013-11-01 15:54:29]  INFO: simple sent SIGTERM
I [2013-11-01 15:54:29]  INFO: simple process stopped
I [2013-11-01 15:54:29]  INFO: simple start: echo "test" > /dev/null
I [2013-11-01 15:54:29]  INFO: simple moved 'up' to 'up'

As far as I can see - the offending lines are here: https://github.com/mojombo/god/blob/master/lib/god/task.rb#L225-L228

Without having tested it, I'd think that changing the condition to orig_to_state != :unmonitored should do the trick - as lifecycle events should be enabled whenever we're not unmonitored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant