Skip to content

Commit

Permalink
Ensure init script is linked into rc.d
Browse files Browse the repository at this point in the history
Also make sure that a daemonized sentinel properly produces
a pid file so the init script can stop the sentinel.
  • Loading branch information
cdent authored and arioch committed Jan 19, 2015
1 parent adeb407 commit 19345cb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
$sentinel_service_name = 'redis-sentinel'
$sentinel_working_dir = '/tmp'
$sentinel_init_template = 'redis/redis-sentinel.init.erb'
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$set_max_intset_entries = 512
$slowlog_log_slower_than = 10000
$slowlog_max_len = 1024
Expand Down
10 changes: 10 additions & 0 deletions manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
#
# Default: 1
#
# [*pid_file*]
# If sentinel is daemonized it will write its pid at this location.
#
# Default: /var/run/redis/redis-sentinel.pid
#
# [*quorum*]
# Number of sentinels that must agree that a master is down to
# signal sdown state.
Expand Down Expand Up @@ -144,6 +149,7 @@
$package_name = $::redis::params::sentinel_package_name,
$package_ensure = $::redis::params::sentinel_package_ensure,
$parallel_sync = $::redis::params::sentinel_parallel_sync,
$pid_file = $::redis::params::sentinel_pid_file,
$quorum = $::redis::params::sentinel_quorum,
$sentinel_port = $::redis::params::sentinel_port,
$service_group = $::redis::params::service_group,
Expand Down Expand Up @@ -185,6 +191,10 @@
content => template($init_template),
require => Package[$package_name];
}
exec {
"/usr/sbin/update-rc.d redis-sentinel defaults":
require => File[$init_script];
}
}

service { $service_name:
Expand Down
4 changes: 4 additions & 0 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
port 26379
dir /tmp
daemonize yes
pidfile /var/run/redis/redis-sentinel.pid
sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
Expand All @@ -16,6 +18,8 @@
port 26379
dir /tmp
daemonize yes
pidfile /var/run/redis/redis-sentinel.pid
sentinel monitor cow 127.0.0.1 6379 2
sentinel down-after-milliseconds cow 6000
sentinel parallel-syncs cow 1
Expand Down
3 changes: 2 additions & 1 deletion templates/redis-sentinel.conf.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
port <%= @sentinel_port %>
dir <%= @working_dir %>
<% if @daemonize -%>daemonize yes<% else -%>daemonize no<% end -%>
<% if @daemonize -%>daemonize yes<% else -%>daemonize no<% end %>
pidfile <%= @pid_file %>

sentinel monitor <%= @master_name %> <%= @redis_host %> <%= @redis_port %> <%= @quorum %>
sentinel down-after-milliseconds <%= @master_name %> <%= @down_after %>
Expand Down
4 changes: 2 additions & 2 deletions templates/redis-sentinel.init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
# Description: redis-server - Persistent key-value db
# Short-Description: redis-sentinel - Monitor redis-server
# Description: redis-sentinel - Monitor redis-server
### END INIT INFO


Expand Down

0 comments on commit 19345cb

Please sign in to comment.