-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First draft of a supervisor cookbook
- Loading branch information
bkonkle
committed
Dec 22, 2010
1 parent
68e5c0e
commit c11c674
Showing
6 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
define :supervisor_program, :autostart => true, do | ||
include_recipe "supervisor" | ||
|
||
if params[:exitcodes] | ||
exitcodes = params[:exitcodes].join(",") | ||
else | ||
exitcodes = nil | ||
end | ||
|
||
if params[:environment] | ||
envsettings = [] | ||
params[:environment].each_pair do |key, value| | ||
envsettings.push("#{key}=#{value}") | ||
end | ||
environment = envsettings.join(",") | ||
else | ||
environment = nil | ||
end | ||
|
||
template "/etc/supervisor/conf.d/#{params[:name].conf}" do | ||
source "program.conf.erb" | ||
user "root" | ||
group "root" | ||
mode "0644" | ||
variables :name => params[:name], | ||
:command => params[:command], | ||
:directory => params[:directory], | ||
:user => params[:user], | ||
:autostart => params[:autostart], | ||
:autorestart => params[:autorestart], | ||
:exitcodes => exitcodes, | ||
:startretries => params[:startretries], | ||
:environment => environment, | ||
:stdout_logfile => params[:stdout_logfile], | ||
:stderr_logfile => params[:stderr_logfile], | ||
:redirect_stderr => params[:redirect_stderr], | ||
:stopsignal => params[:stopsignal] | ||
notifies :reload, resources(:service => "supervisor") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
; supervisor config file | ||
|
||
[unix_http_server] | ||
file=/var/run//supervisor.sock ; (the path to the socket file) | ||
chmod=0700 ; sockef file mode (default 0700) | ||
|
||
[supervisord] | ||
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) | ||
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) | ||
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) | ||
|
||
; the below section must remain in the config file for RPC | ||
; (supervisorctl/web interface) to work, additional interfaces may be | ||
; added by defining them in separate rpcinterface: sections | ||
[rpcinterface:supervisor] | ||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | ||
|
||
[supervisorctl] | ||
serverurl=unix:///var/run//supervisor.sock ; use a unix:// URL for a unix socket | ||
|
||
; The [include] section can just contain the "files" setting. This | ||
; setting can list multiple files (separated by whitespace or | ||
; newlines). It can also contain wildcards. The filenames are | ||
; interpreted as relative to this file. Included files *cannot* | ||
; include files themselves. | ||
|
||
[include] | ||
files = /etc/supervisor/conf.d/*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package "supervisor" | ||
|
||
cookbook_file "/etc/supervisor/supervisord.conf" do | ||
source "supervisord.conf.erb" | ||
owner "root" | ||
group "root" | ||
mode "0644" | ||
end | ||
|
||
service "supervisor" do | ||
supports :status => true, :restart => true, :reload => true | ||
reload_command "supervisorctl update" | ||
action [:enable, :start] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[program:<%= @name %>] | ||
command=<%= @command %> | ||
<% if @directory %>directory=<%= @directory %><% end %> | ||
<% if @user %>user=<%= @user %><% end %> | ||
<% if not @autostart %>autostart=false<% end %> | ||
<% if @autorestart %>autorestart=<%= @autorestart %><% end %> | ||
<% if @exitcodes %>exitcodes=<%= @exitcodes %><% end %> | ||
<% if @startretries %>startretries=<%= @startretries %><% end %> | ||
<% if @environment %>environment=<%= @environment %><% end %> | ||
<% if @stdout_logfile %>stdout_logfile=<%= @stdout_logfile %><% end %> | ||
<% if @stderr_logfile %>stderr_logfile=<%= @stderr_logfile %><% end %> | ||
<% if @redirect_stderr %>redirect_stderr=true<% end %> | ||
<% if @stopsignal %>stopsignal=<%= @stopsignal %><% end %> |