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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

at_exit hooks not called in worker processes #135

Open
avlazarov opened this issue Oct 12, 2022 · 0 comments
Open

at_exit hooks not called in worker processes #135

avlazarov opened this issue Oct 12, 2022 · 0 comments

Comments

@avlazarov
Copy link

avlazarov commented Oct 12, 2022

馃憢

I'm expecting the at_exit block from the worker class to be executed, but it's not

require 'serverengine'

module Worker
  extend self

  def run
    @stopped = false

    at_exit do
      puts 'Running at_exit hook!' # not printed
    end

    trap 'TERM' do
      @stopped = true
    end

    until @stopped
      puts 'Super hard work!'
      sleep 1
    end
  end
end

ServerEngine.create nil, Worker do
  {
    log: '-',
    worker_type: 'process',
  }
end.run

It seems that at_exit hooks are explicitly disabled in the ProcessManager#fork by using Kernel.exit! in the child process. Is there a reason for not allowing the hooks to be run?

P.S I'm aware of the ServerEngine::Worker#stop hook, but the idea is to have the application code (Rails) decide what to install as exit hooks.

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