cookbook 'service_factory', '= 0.1.1'
service_factory (4) Versions 0.1.1 Follow3
LWRPs to generate services using native system features and service managers. (SysV, Upstart, ...)
cookbook 'service_factory', '= 0.1.1', :supermarket
knife supermarket install service_factory
knife supermarket download service_factory
service_factory cookbook
Cookbook for Opscode Chef.
http://community.opscode.com/cookbooks/service_factory
Fully functional … documentation WIP, and example usages coming soon !!
Description
Generate services using native system features with the service_factory
LWRPs.
Your recipe provides the configuration details, and the necessary files are generated to create a SysV or Upstart service, depending on what each OS prefers. (SystemD coming soon!!)
Supported Service Managers
- SysV (init.d, chkconfig, etc.)
- Upstart (Ubuntu, Debian, etc.)
Supported Operating Systems
The following are supported and verified through test-kitchen automated integration testing.
- Centos
- Ubuntu
Requirements
Cookbooks: unix_bin
Resource Documentation
ACTIONS
:create, :delete, :start, :stop, :restart, :enable, :disable
Note: You can also use a standard Chef service resource to manage the service once created.
ATTRIBUTES
attribute = default
description (type)
:service_name
Simple name of service. Defaults to resource name. (/^[a-z0-9_]+$/i)
:service_desc
Short description of service. (Required)
:exec
Full path to executable binary. (Required)
:exec_args = ""
Command line args to executable. (String or Array)
:exec_umask = "0027"
umask set before execution
:exec_forks = false
Does executable fork at startup? (Important)
:process_name = basename %{exec}
Used to detect status and stop service.
:kill_timeout = 5
Number of seconds to wait before killing at stop/shutdown.
:before_start = ""
Shell commands to run before starting service.
:after_start = ""
Shell commands to run after starting service.
:before_stop = ""
Shell commands to run before stopping service.
:after_stop = ""
Shell commands to run after stopping service.
:base_path = ""
Prefix to FHS paths.
Ex. "/srv/myapp" => "/srv/myapp/etc/"
:var_subpath = ( %{run_user} == 'root' ? %{run_group} : %{service_name} )
Suffix added to var directories.
Ex. "myapp" => "/var/run/myapp/appname.pid"
:lock_file = %{base_path}/var/lock/subsys/%{service_name}
Full path to lock file.
:log_file = %{base_path}/var/log/%{var_subpath}/%{service_name}.log
Full path to log file.
:log_what = :none
What service output should be logged. (:std_out :std_err :std_all :none)
:pid_file {base_path}/var/run/{var_subpath}/{service_name}.pid
Full path to pid file.
:create_pid = %{exec_forks} ? false : true
If true the factory creates a pid file, otherwise the daemon should create it.
:run_user
Name or id of user to run service under. (Required)
:run_group
Name or id of group to run service under. (Required)
Recipes
This cookbook only provides LWRPs, no recipes are included.
Attributes
The following attributes / defaults govern the platform selection.
default["service_factory"]["platform_map"]["centos"]["default"] = "init"
default["service_factory"]["platform_map"]["ubuntu"]["default"] = "upstart"
Test-Kitchen
This package is test-kitchen enabled and automatically tested against:
- CentOS 5 and 6
- Ubuntu 10 and 12
A successful test appears as follows:
-----> Running bats test suite
1..6
ok 1 non-forked service
ok 2 forked service
ok 3 sighup restart (non-forked)
ok 4 sighup restart (forked)
ok 5 nobody service
ok 6 deleted service
Finished verifying (1m18.10s).
Development and Maintenance
- Found a bug?
- Need some help?
- Have a suggestion?
- Want to contribute?
Please visit: code.binbab.org
Authors and License
- Author:: BinaryBabel OSS (projects@binarybabel.org)
- Copyright:: 2013
sha1(OWNER) = df334a7237f10846a0ca302bd323e35ee1463931
- License:: Apache License, Version 2.0
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.