Dev set up
This commit is contained in:
29
ops/cookbooks/vendor/memcached/templates/init_systemd.erb
vendored
Normal file
29
ops/cookbooks/vendor/memcached/templates/init_systemd.erb
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
# Systemd unit file for <%= @instance %>
|
||||
|
||||
[Unit]
|
||||
Description=memcached instance <%= @instance %>
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=<%= @user %>
|
||||
LimitNOFILE=<%= @ulimit %>
|
||||
ExecStart=<%= @binary_path %> <%= @cli_options %>
|
||||
Restart=on-failure
|
||||
|
||||
# Various security configurations from:
|
||||
# https://github.com/memcached/memcached/blob/master/scripts/memcached.service
|
||||
PrivateTmp=true
|
||||
ProtectSystem=full
|
||||
NoNewPrivileges=true
|
||||
PrivateDevices=true
|
||||
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
|
||||
RestrictNamespaces=true
|
||||
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
|
||||
RestrictRealtime=true
|
||||
ProtectControlGroups=true
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
MemoryDenyWriteExecute=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
93
ops/cookbooks/vendor/memcached/templates/init_sysv.erb
vendored
Normal file
93
ops/cookbooks/vendor/memcached/templates/init_sysv.erb
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# memcached This shell script takes care of starting and stopping Memcached
|
||||
#
|
||||
# This script based off Atsushi NAGASE's script at https://gist.github.com/ngs/3081846
|
||||
|
||||
# chkconfig: - 55 45
|
||||
### BEGIN INIT INFO
|
||||
# Provides: <%= @instance %>
|
||||
# Required-Start: $network $syslog
|
||||
# Required-Stop: $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Description: The memcached daemon is a network memory cache service.
|
||||
# Processname: memcached
|
||||
# Short-Description: start and stop memcached instance <%= @instance %>
|
||||
### END INIT INFO
|
||||
|
||||
ulimit -n <%= @ulimit %>
|
||||
|
||||
## Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# Source LSB function library.
|
||||
if [ -r /lib/lsb/init-functions ]; then
|
||||
. /lib/lsb/init-functions
|
||||
else
|
||||
echo 'Could not find necessary /lib/lsb/init-functions'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RETVAL=0
|
||||
prog="memcached"
|
||||
|
||||
start () {
|
||||
echo -n $"Starting $prog: "
|
||||
|
||||
# ensure that /var/run/memcached actually exists
|
||||
if [ ! -d /var/run/memcached ]; then
|
||||
mkdir /var/run/memcached
|
||||
fi
|
||||
|
||||
# ensure that /var/run/memcached has proper permissions
|
||||
if [ "`stat -c %U /var/run/memcached`" != "<%= @user %>" ]; then
|
||||
chown <%= @user %> /var/run/memcached
|
||||
fi
|
||||
|
||||
start_daemon -p /var/run/memcached/memcached_<%= @instance %>.pid <%= @binary_path %> -d \
|
||||
-P /var/run/memcached/memcached_<%= @instance %>.pid <%= @cli_options %> >> <%= @log_file %> 2>&1
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch <%= @lock_dir %>/memcached
|
||||
}
|
||||
stop () {
|
||||
echo -n $"Stopping $prog: "
|
||||
killproc -p /var/run/memcached/memcached_<%= @instance %>.pid <%= @binary_path %>
|
||||
RETVAL=$?
|
||||
echo
|
||||
if [ $RETVAL -eq 0 ] ; then
|
||||
rm -f <%= @lock_dir %>/memcached
|
||||
rm -f /var/run/memcached/memcached_<%= @instance %>.pid
|
||||
fi
|
||||
}
|
||||
|
||||
restart () {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status memcached
|
||||
;;
|
||||
restart|reload|force-reload)
|
||||
restart
|
||||
;;
|
||||
condrestart)
|
||||
[ -f <%= @lock_dir %>/memcached ] && restart || :
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
103
ops/cookbooks/vendor/memcached/templates/init_sysv_debian.erb
vendored
Normal file
103
ops/cookbooks/vendor/memcached/templates/init_sysv_debian.erb
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: <%= @instance %>
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: start and stop memcached instance <%= @instance %>
|
||||
# Description: The memcached daemon is a network memory cache service.
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="Description of the service"
|
||||
NAME=<%= @instance %>
|
||||
DAEMON=<%= @binary_path %>
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
DAEMON_ARGS="<%= @cli_options %> -d -P $PIDFILE"
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
ulimit -n <%= @ulimit %>
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 1
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
|
||||
# and status_of_proc is working.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
touch $PIDFILE
|
||||
chown <%= @user %>:root $PIDFILE
|
||||
chmod 660 $PIDFILE
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
||||
|| return 1
|
||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
|
||||
$DAEMON_ARGS >> <%= @log_file %> 2>&1 \
|
||||
|| return 2
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
|
||||
RETVAL="$?"
|
||||
rm -f $PIDFILE
|
||||
return "$RETVAL"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
status_of_proc -p $PIDFILE && exit 0 || exit $?
|
||||
;;
|
||||
restart|force-reload)
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
10
ops/cookbooks/vendor/memcached/templates/init_upstart.erb
vendored
Normal file
10
ops/cookbooks/vendor/memcached/templates/init_upstart.erb
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
description "Memcached instance <%= @instance -%>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [!2345]
|
||||
respawn
|
||||
respawn limit 10 5
|
||||
|
||||
limit nofile <%= @ulimit -%> <%= @ulimit -%>
|
||||
|
||||
exec <%= @binary_path %> <%= @cli_options %> >> <%= @log_file %> 2>&1
|
2
ops/cookbooks/vendor/memcached/templates/sv-memcached-log-run.erb
vendored
Normal file
2
ops/cookbooks/vendor/memcached/templates/sv-memcached-log-run.erb
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec svlogd -tt ./main
|
6
ops/cookbooks/vendor/memcached/templates/sv-memcached-run.erb
vendored
Normal file
6
ops/cookbooks/vendor/memcached/templates/sv-memcached-run.erb
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
|
||||
ulimit -n <%= @options[:ulimit] %>
|
||||
|
||||
exec chpst -u <%= @options[:user] %> <%= @options[:binary_path] %> <%= @options[:cli_options] %>
|
Reference in New Issue
Block a user