From f890005d04c44d1ae70a3204ab819beedcc65035 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Sat, 12 Apr 2014 23:25:21 -0400 Subject: [PATCH] Add docker kill --signal, closes #123 --- CHANGELOG.md | 2 ++ README.md | 10 ++++++++++ providers/container.rb | 5 ++++- resources/container.rb | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da1a4634d..b05cde1cae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Attributes now available for all docker daemon flags as well as system IP forwar * Enhancement: [#118][]: Docker 0.10.0: Add --input flag to docker load * Enhancement: [#119][]: Docker 0.10.0: Add support for --env-file to load environment variables from files * Enhancement: [#120][]: Docker 0.10.0: Deprecate docker insert +* Enhancement: [#123][]: Add docker kill --signal * Enhancement: [#124][]: Add all docker daemon options as attributes * Enhancement: [#125][]: Use dns* attributes to set docker daemon options, not defaults per-container * Enhancement: [#128][]: Add checksum attribute for binary downloads @@ -455,6 +456,7 @@ Lots of community contributions this release -- thanks! [#118]: https://github.com/bflad/chef-docker/issues/118 [#119]: https://github.com/bflad/chef-docker/issues/119 [#120]: https://github.com/bflad/chef-docker/issues/120 +[#123]: https://github.com/bflad/chef-docker/issues/123 [#124]: https://github.com/bflad/chef-docker/issues/124 [#125]: https://github.com/bflad/chef-docker/issues/125 [#126]: https://github.com/bflad/chef-docker/issues/126 diff --git a/README.md b/README.md index f9058993f6..ffc0f86371 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,7 @@ Attribute | Description | Type | Default cookbook | Cookbook to grab any templates | String | docker init_type | Init type for container service handling | FalseClass, String | `node['docker']['container_init_type']` init_template | Template to use for init configuration | String | nil +signal | Signal to send to the container | String | nil (implicitly KILL) socket_template | Template to use for configuring socket (relevent for init_type systemd only) | String | nil Kill a running container: @@ -353,6 +354,15 @@ docker_container 'shipyard' do end ``` +Send SIGQUIT to a running container: + +```ruby +docker_container 'shipyard' do + signal 'QUIT' + action :kill +end +``` + #### docker_container action :redeploy Stops, removes, and runs a container. Useful for notifications from image build/pull. diff --git a/providers/container.rb b/providers/container.rb index 5e04dd804e..c8c0e306b0 100644 --- a/providers/container.rb +++ b/providers/container.rb @@ -240,7 +240,10 @@ def kill if service? service_stop else - docker_cmd!("kill #{current_resource.id}") + kill_args = cli_args( + 'signal' => new_resource.signal + ) + docker_cmd!("kill #{kill_args} #{current_resource.id}") end end diff --git a/resources/container.rb b/resources/container.rb index b17f66a107..d2e22bb865 100644 --- a/resources/container.rb +++ b/resources/container.rb @@ -42,6 +42,7 @@ attribute :remove_automatically, :kind_of => [TrueClass, FalseClass], :default => false attribute :repository, :kind_of => [String] attribute :run, :kind_of => [String] +attribute :signal, :kind_of => [String] attribute :socket_template, :kind_of => [String] attribute :source, :kind_of => [String] attribute :status, :kind_of => [String]