forked from sous-chefs/consul
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sous-chefs#320 from paybyphone/delay_upstart_start…
…ed_event Added post-start script to upstart config to delay service started event until consul ready to serve requests
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# <%= @name %> generated by poise-service for <%= @new_resource.to_s %> | ||
|
||
description "<%= @name %>" | ||
|
||
start on runlevel [2345] | ||
stop on runlevel [!2345] | ||
|
||
respawn | ||
respawn limit 10 5 | ||
umask 022 | ||
chdir <%= @directory %> | ||
<%- @environment.each do |key, val| -%> | ||
env <%= key %>="<%= val %>" | ||
<%- end -%> | ||
<%- if @upstart_features[:setuid] -%> | ||
setuid <%= @user %> | ||
<%- end -%> | ||
<%- if @upstart_features[:kill_signal] -%> | ||
kill signal <%= @stop_signal %> | ||
<%- end -%> | ||
<%- if @upstart_features[:reload_signal] -%> | ||
reload signal <%= @reload_signal %> | ||
<%- end -%> | ||
|
||
<%- if @upstart_features[:setuid] -%> | ||
exec <%= @command %> | ||
<%- else -%> | ||
script | ||
exec /opt/chef/embedded/bin/ruby <<EOH | ||
require 'etc' | ||
ent = Etc.getpwnam(<%= @user.inspect %>) | ||
if Process.euid != ent.uid || Process.egid != ent.gid | ||
Process.initgroups(ent.name, ent.gid) | ||
Process::GID.change_privilege(ent.gid) if Process.egid != ent.gid | ||
Process::UID.change_privilege(ent.uid) if Process.euid != ent.uid | ||
end | ||
ENV["HOME"] = Dir.home(<%= @user.inspect %>) rescue nil | ||
exec(*<%= Shellwords.split(@command).inspect %>) | ||
EOH | ||
end script | ||
<%- end -%> | ||
<%- if !@upstart_features[:kill_signal] && @stop_signal != 'TERM' -%> | ||
pre-stop script | ||
PID=`initctl status <%= @name %> | sed 's/^.*process \([0-9]*\)$/\1/'` | ||
if [ -n "$PID" ]; then | ||
kill -<%= @stop_signal %> "$PID" | ||
fi | ||
end script | ||
<%- end -%> | ||
post-start script | ||
while ! <%= @options[:executable] %> info ; sleep 1; done | ||
end script |
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