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

Allow for an ADHoc Sending of a signal to a ContainerPilot job. #571

Open
Smithx10 opened this issue Jul 14, 2018 · 1 comment
Open

Allow for an ADHoc Sending of a signal to a ContainerPilot job. #571

Smithx10 opened this issue Jul 14, 2018 · 1 comment

Comments

@Smithx10
Copy link

Problem:

Send a HUP, TERM, or KILL signal to a job running in ContainerPilot without having to subscribe to the SIGHUP and SIGUSR2 handlers that CP is running.

I discovered the need for this functionality while dealing with applications that don't support PID Files or a simple way of discovering the pid.
In this particular case ( elastic/logstash#3577 (comment) ) the maintainers refuse to implement the functionality, and have decided this is the job of the init system.

Proposed Solution:

Add "-termjob 'jobname'", "-killjob 'jobname'", and "-reloadjob 'jobname'" to the ContainerPilot control plane.

Behavior:

-termjob, will send the TERM signal to the provided jobname.
-killjob, will send the KILL signal to the provided jobname.
-reloadjob will send the HUP signal to the provided jobname.

Useful example:

In the autopilot pattern we run into situations where we need to change a job's configuration, and then send the appropriate signal to the corresponding jobs.

consul-template \
  -template "./logstash.yml.ctmpl:./logstash.yml:containerpilot -reloadjob 'logstash'

or if logstash can't reload our change with a HUP, restart it with a TERM.

consul-template \
  -template "./logstash.yml.ctmpl:./logstash.yml:containerpilot -termjob 'logstash'

or if we really really want to be brave, we can KILL it quickly.

consul-template \
  -template "./logstash.yml.ctmpl:./logstash.yml:containerpilot -killjob 'logstash'

kill and term should only apply to jobs where restarts are allowed.

Confession:

#513 Can accommodate most of this, but I can envision a circumstance where this pattern might be more convenient and easier for people to use, and reason about. I didn't see 513, until I wrote the first bit of code.

Possible negative impacts:

I can't really find any possible future issues with having this feature in the Control Plane if implemented correctly. The current Signal handler should co-exist without issue.

@mterron
Copy link
Contributor

mterron commented Jul 26, 2018

Would a more generic approach syntax be useful? Something along the lines of:

$ containerpilot -job 'logstash' -signal SIGNAL

Maybe supporting signal names and the corresponding signal number?

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

No branches or pull requests

3 participants