mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-11 00:02:05 -05:00
40 lines
734 B
Ruby
40 lines
734 B
Ruby
require 'spec_helper'
|
|
require 'demon/base'
|
|
|
|
describe Demon do
|
|
|
|
class RudeDemon < Demon::Base
|
|
def self.prefix
|
|
"rude"
|
|
end
|
|
|
|
def after_fork
|
|
Signal.trap("HUP"){}
|
|
Signal.trap("TERM"){}
|
|
sleep 999999
|
|
end
|
|
end
|
|
|
|
it "can terminate rude demons" do
|
|
|
|
skip("forking rspec has side effects")
|
|
# Forking rspec has all sorts of weird side effects
|
|
# this spec works but we must skip it to keep rspec
|
|
# state happy
|
|
|
|
|
|
RudeDemon.start
|
|
_,demon = RudeDemon.demons.first
|
|
pid = demon.pid
|
|
wait_for {
|
|
demon.alive?
|
|
}
|
|
|
|
demon.stop_timeout = 0.05
|
|
demon.stop
|
|
demon.start
|
|
|
|
running = !!(Process.kill(0, pid)) rescue false
|
|
expect(running).to eq(false)
|
|
end
|
|
end
|