Simple Puppet module for creating and managing init_scripts
- Compatible with init.d, chkconfig and update-rc.
- Creates an init script and service, and can ensure the service is running.
- Supports running executables as different users.
- Easily redirect all output to a logfile.
init_script { 'ffmpeg_input':
daemon_name => 'ffmpeg_input',
daemon_path => '/usr/local/bin',
daemon_bin => 'ffmpeg',
}
or
init_script { 'ffmpeg_input':
daemon_name => 'ffmpeg_input',
daemon_path => '/usr/local/bin',
daemon_bin => 'ffmpeg',
daemon_opts => '-i udp://127.0.0.1:5001 /tmp/test.mp4',
daemon_env_setup => 'ALSA_ENABLE=false',
}
####Required
daemon_name
: The name for the daemon. This sets the "Provides: " metadata tag required for init.d systems, and processname for chkconfig. Type: stringdaemon_path
: The path to the daemon binary. Type: stringdaemon_bin
: The binary file to run. Type: string
####Optional
daemon_desc
: The description to set in the chkconfig/lsb header. Type: stringdaemon_user
: The user to run the daemon as. Must exist already, specified by username. Type:string. Default: rootdaemon_opts
: Any options to pass to the daemon binary. Type: stringdaemon_env_setup
: A command that can be executed before the daemon binary is run, normally to setup the environment. Useful for virtualenv activate statements. Type: stringdaemon_required_start
: init.d systems only Defines any services that are required to start before this one. See lsb/init.d documentation for more details.external_pid
: Path to an external PID file, if one is created by the application. Useful if a wrapper script is used to launch it - echo the PID(s) of your application to a text file and set this parameter to the same path. Type: stringkill_by_name
: If true, the init.d script will kill the process using pgrep combined with a process name and argument string. If this is set to true,kill_by_pid
must be set to false explicitly, and you must supplykill_proc_name
with an optionalkill_proc_args
. Use this with caution. This function is particularly useful if the application spawns several processes that don't die with the parent. Seekill_proc_name
andkill_proc_args
for more information. Type: boolean. Default: falsekill_by_pid
: If true, the init script will kill the process using its PID, whether this is obtained by the script or read from the file defined in external_pid. Type: boolean. Default: truekill_proc_name
: The process name to use with pgrep in order to kill the script. See pgrep documentation for more details. Note: pgrep accepts regular expressions in it's process names. Type: stringkill_proc_args
: The process arguments to use with pgrep in order to kill the script. If supplied, pkill/pgrep are called with the -f flag supplying these as arguments. See prgep documentation for more details. Type: stringdaemon_logfile
: The logfile to redirect any stdout generated by the service to. Type: string. Default: /dev/nullchkconfig
: The chkconfig runlevels string to supply in the header. See chkconfig documentation for more details.
Initial release. Works with lsb and chkconfig.
Benjamin Bettridge [email protected]
2014-11-19
Copyright 2014 Ben Bettridge
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.