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

[Question] Using Runit Service Discovery #72

Closed
mickelsonm opened this issue Feb 15, 2014 · 6 comments
Closed

[Question] Using Runit Service Discovery #72

mickelsonm opened this issue Feb 15, 2014 · 6 comments

Comments

@mickelsonm
Copy link

I noticed that the supported service discovery types are Systemd and Upstart. My needs require Runit, which I was able to get something quickly working. Below are my main files that I use to achieve this:

runit.config.erb

#!/bin/sh
exec 2>&1
exec docker start <%= @app.name %>

create the service items

directory "/etc/sv/#{app.name}/" do
    action :create
end

template "/etc/sv/#{app.name}/run" do
    source "runit.config.erb"
    user  "root"
    owner "root"
    group "root"
    variables({
        :app => app,
    })
    mode 0755
    action :create
end

link "/etc/service/#{app.name}" do 
    to "/etc/sv/#{app.name}"
    mode 0755
    link_type :symbolic
    action :create
end

My question is if there is a more elegant/better way to achieve this? I would greatly prefer if I could achieve the same results using the chef-docker cookbook. I am new to Chef and Ruby, so all help is greatly appreciated. Thanks!

@bflad
Copy link
Contributor

bflad commented Feb 15, 2014

First of all, I should add runit support for you so you don't have to manually do this. Should be fairly doable with how I have things setup correctly and can support both the docker daemon and docker_container resources.

I'd highly recommend using the Chef community runit cookbook: https://github.com/hw-cookbooks/runit, which is what I'd base any implementation of mine on (using the runit_service resource). The Heavy Water folks and contributors have already done most, if not all, of the heavy lifting for runit!

Hope this helps. Will keep open until runit support is added.

@mickelsonm
Copy link
Author

Thanks for the help and willingness to extend the existing functionality. I have the runit cookbook being used as a dependency for my web server (Nginx), so I guess I have looked into it somewhat, but was stumbling to try to figure out how to get it to work with the chef-docker cookbook. I definitely am looking forward to this new functionality!

@bflad
Copy link
Contributor

bflad commented Feb 16, 2014

Released initial support for runit in 0.31.0 of the cookbook. Set your init_type or container_init_type attributes to runit and hopefully this will get you started.

@mickelsonm
Copy link
Author

I just started testing Runit again. I set the "container_init_type": "runit". When I run my recipe a second time and when it hits the section for stopping a container it errors out.

I have the following to stop a potential running container:

docker_container "#{app.name}" do
  action :stop
end

Error I get:

Recipe: deployment::none
  * service[webapp] action stop
    * /etc/init.d/webapp does not exist!
================================================================================
Error executing action `stop` on resource 'service[webapp]'
================================================================================


Chef::Exceptions::Service
-------------------------
/etc/init.d/webapp does not exist!


Resource Declaration:
---------------------
# In /home/deployer/chef-solo/cookbooks-2/docker/providers/container.rb

238:   service service_name do
239:     case new_resource.init_type
240:     when 'systemd'
241:       provider Chef::Provider::Service::Systemd
242:     when 'upstart'
243:       provider Chef::Provider::Service::Upstart
244:     end
245:     supports :status => true, :restart => true, :reload => true



Compiled Resource:
------------------
# Declared in /home/deployer/chef-solo/cookbooks-2/docker/providers/container.rb:238:in `service_action'

service("webapp") do
  action [:stop]
  supports {:status=>true, :restart=>true, :reload=>true}
  retries 0
  retry_delay 2
  service_name "webapp"
  pattern "webapp"
  cookbook_name :"deployment"
  recipe_name "none"
end

Any ideas or things I need to set to get this to work in my Debian 7 environment? Thanks!

@bflad
Copy link
Contributor

bflad commented Mar 25, 2014

@mickelsonm are you still having trouble with runit?

@mickelsonm
Copy link
Author

@bflad : Hey thanks for the follow-up! Unfortunately,I wasn't able to get it to go. I am trying to remember what I tried (month ago...sorry), but I do remember setting "container_init_type": "runit", which partially worked the first time I ran my deployment script, but on the second time it raised the error I mentioned.Not really sure on the how or why without re-testing it.

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

2 participants