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

Trying to use Hooks to stop processes Circus don't stop #1031

Open
paulocheque opened this issue Mar 20, 2017 · 0 comments
Open

Trying to use Hooks to stop processes Circus don't stop #1031

paulocheque opened this issue Mar 20, 2017 · 0 comments

Comments

@paulocheque
Copy link

paulocheque commented Mar 20, 2017

I am trying to create an workaround for the #986 issue.

But this creates two processes for the same watcher. Ideas?

import os
import subprocess


# hooks.after_spawn = fix_circus.save_pid
def save_pid(watcher, arbiter, hook_name, pid, **kwargs):
    with open('api.pid', 'w') as f:
        f.write(str(pid))
    return True


# hooks.after_stop = fix_circus.force_kill
def force_kill(watcher, arbiter, hook_name, **kwargs):
    with open('api.pid', 'r') as f:
        pid = f.read()
        print('Force killing {} process'.format(pid))
        subprocess.call(['kill', '-KILL', pid])
    os.remove('api.pid')
    return True
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