Skip to content

Commit

Permalink
Merge pull request #127 from jhmartin/125_Startup-delay
Browse files Browse the repository at this point in the history
Delay return of control during startup
  • Loading branch information
johnbellone committed Jul 13, 2015
2 parents 02433d9 + b238d7c commit a8d3060
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ Installs and configures [Consul][1] client, server and UI.
</td>
<td><tt>nil</tt></td>
</tr>
<tr>
<td><tt>['consul']['startup_sleep']</tt></td>
<td>Integer</td>
<td>
Delay to return-of-control when invoked via an init.d script. Protects consul from an early HUP.
</td>
<td><tt>3</tt></td>
</tr>
</table>

### Databag Attributes (optional)
Expand Down
3 changes: 3 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@
default['consul']['atlas_autojoin'] = false
default['consul']['atlas_cluster'] = nil
default['consul']['atlas_token'] = nil

# Init script startup delay
default['consul']['startup_sleep'] = 3
3 changes: 2 additions & 1 deletion recipes/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@
source init_tmpl
mode init_mode
variables(
consul_logfile: node['consul']['logfile']
consul_logfile: node['consul']['logfile'],
startup_sleep: node['consul']['startup_sleep']
)
notifies :restart, 'service[consul]', :immediately
end
Expand Down
1 change: 1 addition & 0 deletions templates/default/consul-init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ case "$1" in
CONSULPID=$!
echo $CONSULPID > "$PIDFILE"
TIMEOUT="$STARTIMEOUT"
sleep <%= @startup_sleep %>
while [ $TIMEOUT -gt 0 ]; do
if is_running; then
break
Expand Down

0 comments on commit a8d3060

Please sign in to comment.