Skip to content

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

Description

@Smithx10

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions