Dev set up
This commit is contained in:
383
ops/cookbooks/vendor/runit/CHANGELOG.md
vendored
Normal file
383
ops/cookbooks/vendor/runit/CHANGELOG.md
vendored
Normal file
@ -0,0 +1,383 @@
|
||||
# runit Cookbook CHANGELOG
|
||||
|
||||
This file is used to list changes made in each version of the runit cookbook.
|
||||
|
||||
## 5.1.1 (2019-05-29)
|
||||
|
||||
- Add a new use_init_script_sv_link property - [@tas50](https://github.com/tas50)
|
||||
- Test on Chef 14 and Chef 15 in Travis - [@tas50](https://github.com/tas50)
|
||||
- Correct pass in the signal variable for the control config - [@markan](https://github.com/markan)
|
||||
- Remove Ubuntu 14.04 Kitchen tests - [@tas50](https://github.com/tas50)
|
||||
|
||||
## 5.1.0 (2019-04-25)
|
||||
|
||||
- Add a new reload_log action - [@tas50](https://github.com/tas50)
|
||||
|
||||
## 5.0.1 (2019-02-11)
|
||||
|
||||
- Resolve an undefined method error for sv_bin
|
||||
- Fix the cookbook incorrectly requiring Chef 13 when it now actually requires Chef 14 due to the use of find_resource. Sorry about this everyone.
|
||||
|
||||
## 5.0.0 (2019-02-04)
|
||||
|
||||
- This cookbook now requires Chef 13 or later. If you are still using Chef 12 please pin to the 4.3.1 release, and also seriously consider upgrading to the latest Chef to receive new features, bug fixes, and security updates in Chef.
|
||||
- Performed a large-scale refactor of the resource to use the Chef resource DSL which resolves multiple edge case bugs by natively setting up properties, default values, and overrides
|
||||
- Updated the default recipe to support Amazon Linux 2
|
||||
- Default attributes used by the resource have been removed from the attributes file. They will continue to work, but their usage should be heavily discouraged as this mixed attributes + properties and results in confusion on where values come from.
|
||||
- Formally deprecated the legacy `options` property in the readme
|
||||
- Removed some legacy backwards compatibility code for older Chef releases we no longer support
|
||||
- Fixed broken integratino tests so we can better test this cookbook
|
||||
- Added Amazon Linux 2 and Ubuntu 18.04 testing in Travis
|
||||
- Consolidated mutliple helper methods into the resource itself for clarity
|
||||
|
||||
## 4.3.1 (2019-01-14)
|
||||
|
||||
- Fixing plat_specific_sv_name logic to work with Amazon Linux 2 - [@mbaitelman](https://github.com/mbaitelman)
|
||||
|
||||
## 4.3.0 (2018-07-24)
|
||||
|
||||
- Fixing plat_specific_sv_name logic to work with Amazon Linux 2
|
||||
- Fixing upstart logic to work with older Amazon versions
|
||||
|
||||
## 4.2.0 (2018-07-24)
|
||||
|
||||
- Don't double start when creating new services
|
||||
- Quoting the timeout value prevents it being cast to an unsigned long.
|
||||
- Add a new log_flags property for changing the default -tt logging flag
|
||||
|
||||
## 4.1.2 (2018-07-18)
|
||||
|
||||
- Make Ubuntu the same as Debian where we template out a script instead of symlinking /etc/init.d/servicename to sv
|
||||
|
||||
## 4.1.1 (2018-04-26)
|
||||
|
||||
- Fix typo in an error message
|
||||
|
||||
## 4.1.0 (2018-04-19)
|
||||
|
||||
- Also install the runit-systemd package on newer Ubuntus
|
||||
- Remove chefspec matchers since they're auto generated by ChefDK now
|
||||
|
||||
## 4.0.4 (2017-12-20)
|
||||
|
||||
- Amazon on Chef 12 fix and additional testing
|
||||
- Add unit tests for each platform we support
|
||||
- Remove the old attributes for controlling the service
|
||||
|
||||
## 4.0.3 (2017-11-29)
|
||||
|
||||
- Remove the custom resource implementation that leaked in and was causing chefspec failures on Chef 12
|
||||
- Convert all the service suite integration tests to inspec
|
||||
|
||||
## 4.0.2 (2017-11-29)
|
||||
|
||||
- Don't fail on Debian 7 where the runsvdir init script doesn't exist
|
||||
|
||||
## 4.0.1 (2017-11-29)
|
||||
|
||||
- Fix compile failures that caused chefspec and runtime failures
|
||||
- Enable amazon linux testing of the default recipe in Travis
|
||||
|
||||
## 4.0.0 (2017-11-24)
|
||||
|
||||
- Fail if we're on an unsupported platform in the main recipe instead of silently continuing
|
||||
- Manage the actual runit service. Without this the runit service may not actually be started which means any service using runit won't actually start at boot
|
||||
- Update the readme to not refer to providers and properly call the resource's property actual proeprties
|
||||
- Add Debian testing to Travis
|
||||
- Move file and templates out of the default dir since only Chef 11 needs this
|
||||
- Use runit-systemd on Debian 9+ since runit package is actually designed for using runit as the main system init system
|
||||
- Remove extra files from the test recipes
|
||||
- Add a test for runit-systemd and use the process inspec resource
|
||||
|
||||
## 3.0.6 (2017-11-16)
|
||||
|
||||
- Test with Local Delivery instead of Rake
|
||||
- Update apache2 license string
|
||||
- Fully support Amazon Linux
|
||||
|
||||
## 3.0.5 (2017-01-25)
|
||||
|
||||
- Don’t mask errors from shellout helper if the binary is present.
|
||||
- Don't error stopping a service that doesn't exist
|
||||
|
||||
## 3.0.4 (2017-01-24)
|
||||
|
||||
- Cookstyle fixes
|
||||
- Update the cookbook description
|
||||
- Check that chef_version exists before declaring it
|
||||
|
||||
## 3.0.3 (2016-12-07)
|
||||
|
||||
- Convert main suite test spec to inspec
|
||||
- Add a number of debug statements to the provider to make debugging failed runs easier
|
||||
- Fix faulty shell outs in the status commands that caused silent failures introduced in the 3.0.2 release
|
||||
|
||||
## 3.0.2 (2016-12-05)
|
||||
- Remove unused helper method runit_sv_works?
|
||||
- Use our new official Oracle images in Test Kitchen
|
||||
- Update wording to clarify that we’re deleting not ‘zapping’ files
|
||||
- Don’t hang forever if Runit isn’t installed when using the provider
|
||||
- Check for the runit binary before every shellout
|
||||
- Remove Fedora support since it doesn’t work
|
||||
|
||||
## 3.0.1 (2016-12-05)
|
||||
- Set service to restart on env changes
|
||||
|
||||
## 3.0.0 (2016-09-16)
|
||||
- Testing updates
|
||||
- Require Chef 12.1+
|
||||
|
||||
## 2.0.0 (2016-08-30)
|
||||
|
||||
- Remove support for Gentoo as we have no way to test this
|
||||
- Remove the empty library file
|
||||
- Run specs against the latest RHEL 5
|
||||
- Basic convergence testing in Travis CI
|
||||
- Remove the need for apt in test kitchen
|
||||
|
||||
## 1.8.1 (2016-08-30)
|
||||
|
||||
- Enable runit installation in Oracle Linux systems
|
||||
- Remove double oracle in the metadata
|
||||
|
||||
## 1.8.0
|
||||
|
||||
- Breaking change: Removed support for EOL Ubuntu platforms (i.e. versions 6.10, 7.04, 7.10, 8.04) (#194)
|
||||
- Added a dependency on yum-epel for RHEL platforms
|
||||
- Breaking change: Removed logic which skipped waiting for named pipe when running inside Docker (#193)
|
||||
- This cookbook is now managed by the Chef Community team and is located at <http://www.github.com/chef-cookbooks/runit>
|
||||
- Cookbook development is now occurring on the master branch with releases taking place after merging. The development branch will be removed
|
||||
- Added a .foodcritic file to ignore FC004
|
||||
- Updated platforms to test in the Test Kitchen file
|
||||
- Replaced the Cheffile with a Berksfile
|
||||
- Moved the specs to the specs directory and removed logic to detect the depsolver
|
||||
- Replaced Rubocop with Cookstyle
|
||||
- Added basic testing in Travis CI
|
||||
- Silenced deprecation warnings in the Chefspecs and removed the Chef 12.5 pin that was used to do the same previously
|
||||
- Added maintainers.md and maintainers.toml files
|
||||
- Removed Gentoo as an officially supported platform as we're not testing this
|
||||
- Added additional RHEL derivatives as supported platforms in metadata.rb
|
||||
- Added chef_version, source_url, and issues_url metadata to metadata.rb
|
||||
|
||||
## v1.7.8
|
||||
|
||||
- Add missing goals to Debian init script template (#175)
|
||||
- Enhancement: Mark `env` files as sensitive (#182)
|
||||
- Reduce warning spam in Chef ~12.7 (#183)
|
||||
- Enhancement: Add support for specifying supervising user and/or group for managing service (#187)
|
||||
|
||||
## v1.7.6
|
||||
|
||||
- Ensure `supervise/ok` named pipe is properly removed when disabling a service, so that it can be enabled again (#166, #167, #172)
|
||||
- Restore `restart_on_update` functionality originally added in [#20](https://github.com/hw-cookbooks/runit/pull/20) and lost in the 1.7.0 refactor.
|
||||
- Update test cookbooks to fix broken tests revealed by restoring `restart_on_update` functionality. Now using socat instead of netcat.
|
||||
|
||||
## v1.7.4 (2015-10-13)
|
||||
|
||||
- Ensure the service directory exists so that we will succeed when enabling services (#153)
|
||||
- Fix regression where env directory contents were being deleted when the `env` attribute is empty. (#144, #158)
|
||||
- Add `log_dir` attribute, used only when `default_logger` is true. (#135)
|
||||
- Ensure svlogd configuration is linked into correct path (#83, #135)
|
||||
- Update README and CHANGELOG for v1.7.0 to warn against known regressions (#144, #157)
|
||||
- Avoid mutating resource options for Chef 12 compatability (#147, #150, #156)
|
||||
- Fix regression regarding waiting for the service socket before running (#138, #142)
|
||||
- Reimplement idempotence checks for `runit_service` resources (#137, #141)
|
||||
- Enhance ChefSpec unit test coverage with specs that step into the LWRP (#139)
|
||||
- Deduplicate ServerSpec integration test coverage using example groups (#140)
|
||||
|
||||
## v1.7.2 (2015-06-19)
|
||||
|
||||
- Re-add missing runit_service actions start, stop, reload and status
|
||||
|
||||
## v1.7.0 (2015-06-18)
|
||||
|
||||
**NOTE**: With the benefit of hindsight we can say that the changes contained in this release merit a major version number change. Please be sure to test this new version for compatibility with your systems before upgrading to version 1.7.
|
||||
|
||||
- Modernize runit_service provider by rewriting pure Ruby as LWRP (#107)
|
||||
- Modernize integration tests by rewriting Minitest suites as ServerSpec (#107)
|
||||
- Fix regression in support for alternate sv binary on debian platforms (#92, #123)
|
||||
- Fix regression in default logger's config location (#117)
|
||||
- Tighten permissions on environment variable config files from 0644 to 0640 (#125)
|
||||
- Add `start_down` and `delete_downfile` attributes to support configuring services with default state of 'down' (#105)
|
||||
|
||||
## v1.6.0 (2015-04-06)
|
||||
|
||||
- Fedora 21 support
|
||||
- Kitchen platform updates
|
||||
- use imeyer's packagecloud repo for RHEL
|
||||
- fix converge_by usage
|
||||
- do_action helper to set updated_by_last_action
|
||||
- style fixes to provider
|
||||
|
||||
## v1.5.18 (2015-03-13)
|
||||
|
||||
- Add helper methods to detect installation presence
|
||||
|
||||
## v1.5.16 (2015-02-11)
|
||||
|
||||
- Allow removal of env files(nhuff)
|
||||
|
||||
## v1.5.14 (2015-01-15)
|
||||
|
||||
- Provide create action(clako)
|
||||
|
||||
## v1.5.12 (2014-12-15)
|
||||
|
||||
- prevent infinite loop inside docker container
|
||||
- runit service failing inside docker container
|
||||
- move to librarian-chef for kitchen dependency resolution
|
||||
- update tests
|
||||
- updates to chefspec matchers
|
||||
|
||||
## v1.5.10 (2014-03-07)
|
||||
|
||||
PR #53- Fix runit RPM file location for Chef provisionless Centos 5.9 Box Image
|
||||
|
||||
## v1.5.9
|
||||
|
||||
Fix runit RPM file location for Chef provisionless Centos 5.9 Box Image
|
||||
|
||||
## v1.5.8
|
||||
|
||||
Fixing string interpolation bug
|
||||
|
||||
## v1.5.3
|
||||
|
||||
Fixing assignment/compare error
|
||||
|
||||
## v1.5.1
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3950](https://tickets.chef.io/browse/COOK-3950)** - runit cookbook should use full service path when checking running status
|
||||
|
||||
## v1.5.0
|
||||
|
||||
### Improvement
|
||||
|
||||
- **[COOK-3267] - Improve testing suite in runit cookbook
|
||||
- Updating test-kitchen harness
|
||||
- Cleaning up style for rubocop
|
||||
|
||||
## v1.4.4
|
||||
|
||||
fixing metadata version error. locking to < 3.0
|
||||
|
||||
## v1.4.2
|
||||
|
||||
Locking yum dependency to '< 3'
|
||||
|
||||
## v1.4.0
|
||||
|
||||
[COOK-3560] Allow the user to configure runit's timeout (-w) and verbose (-v) settings
|
||||
|
||||
## v1.3.0
|
||||
|
||||
### Improvement
|
||||
|
||||
- **[COOK-3663](https://tickets.chef.io/browse/COOK-3663)** - Add ./check scripts support
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3271](https://tickets.chef.io/browse/COOK-3271)** - Fix an issue where runit fails to install rpm package on rehl systems
|
||||
|
||||
## v1.2.0
|
||||
|
||||
### New Feature
|
||||
|
||||
- **[COOK-3243](https://tickets.chef.io/browse/COOK-3243)** - Expose LSB init directory as a configurable
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3182](https://tickets.chef.io/browse/COOK-3182)** - Do not hardcode rpmbuild location
|
||||
|
||||
### Improvement
|
||||
|
||||
- **[COOK-3175](https://tickets.chef.io/browse/COOK-3175)** - Add svlogd config file support
|
||||
- **[COOK-3115](https://tickets.chef.io/browse/COOK-3115)** - Add ability to install 'runit' package from Yum
|
||||
|
||||
## v1.1.6
|
||||
|
||||
### Bug
|
||||
|
||||
- [COOK-2353]: Runit does not update run template if the service is already enabled
|
||||
- [COOK-3013]: Runit install fails on rhel if converge is only partially successful
|
||||
|
||||
## v1.1.4
|
||||
|
||||
### Bug
|
||||
|
||||
- [COOK-2549]: cannot enable_service (lwrp) on Gentoo
|
||||
- [COOK-2567]: Runit doesn't start at boot in Gentoo
|
||||
- [COOK-2629]: runit tests have ruby 1.9 method chaning syntax
|
||||
- [COOK-2867]: On debian, runit recipe will follow symlinks from /etc/init.d, overwrite /usr/bin/sv
|
||||
|
||||
## v1.1.2
|
||||
|
||||
- [COOK-2477] - runit cookbook should enable EPEL repo for CentOS 5
|
||||
- [COOK-2545] - Runit cookbook fails on Amazon Linux
|
||||
- [COOK-2322] - runit init template is broken on debian
|
||||
|
||||
## v1.1.0
|
||||
|
||||
- [COOK-2353] - Runit does not update run template if the service is already enabled
|
||||
- [COOK-2497] - add :nothing to allowed actions
|
||||
|
||||
## v1.0.6
|
||||
|
||||
- [COOK-2404] - allow sending sigquit
|
||||
- [COOK-2431] - gentoo - it should create the runit-start template before calling it
|
||||
|
||||
## v1.0.4
|
||||
|
||||
- [COOK-2351] - add `run_template_name` to allow alternate run script template
|
||||
|
||||
## v1.0.2
|
||||
|
||||
- [COOK-2299] - runit_service resource does not properly start a non-running service
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- [COOK-2254] - (formerly CHEF-154) Convert `runit_service` definition to a service resource named `runit_service`.
|
||||
|
||||
This version has some backwards incompatible changes (hence the major version bump). It is recommended that users pin the cookbook to the previous version where it is a dependency until this version has been tested in a non-production environment (use version 0.16.2):
|
||||
|
||||
```
|
||||
depends "runit", "<= 0.16.2"
|
||||
```
|
||||
|
||||
If you use Chef environments, pin the version in the appropriate environment(s).
|
||||
|
||||
**Changes of note**
|
||||
|
||||
1. The "runit" recipe must be included before the runit_service resource can be used.
|
||||
2. The `runit_service` definition created a separate `service` resource for notification purposes. This is still available, but the only actions that can be notified are `:start`, `:stop`, and `:restart`.
|
||||
3. The `:enable` action blocks waiting for supervise/ok after the service symlink is created.
|
||||
4. User-controlled services should be created per the runit documentation; see README.md for an example.
|
||||
5. Some parameters in the definition have changed names in the resource. See below.
|
||||
|
||||
The following parameters in the definition are renamed in the resource to clarify their intent.
|
||||
|
||||
- directory -> sv_dir
|
||||
- active_directory -> service_dir
|
||||
- template_name -> use service_name (name attribute)
|
||||
- nolog -> set "log" to false
|
||||
- start_command -> unused (was previously in the "service" resource)
|
||||
- stop_command -> unused (was previously in the "service" resource)
|
||||
- restart_command -> unused (was previously in the "service" resource)
|
||||
|
||||
## v0.16.2
|
||||
|
||||
- [COOK-1576] - Do not symlink /etc/init.d/servicename to /usr/bin/sv on debian
|
||||
- [COOK-1960] - default_logger still looks for sv-service-log-run template
|
||||
- [COOK-2035] - runit README change
|
||||
|
||||
## v0.16.0
|
||||
|
||||
- [COOK-794] default logger and `no_log` for `runit_service` definition
|
||||
- [COOK-1165] - restart functionality does not work right on Gentoo due to the wrong directory in the attributes
|
||||
- [COOK-1440] - Delegate service control to normal user
|
||||
|
||||
## v0.15.0
|
||||
|
||||
- [COOK-1008] - Added parameters for names of different templates in runit
|
2
ops/cookbooks/vendor/runit/CONTRIBUTING.md
vendored
Normal file
2
ops/cookbooks/vendor/runit/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
Please refer to
|
||||
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
|
390
ops/cookbooks/vendor/runit/README.md
vendored
Normal file
390
ops/cookbooks/vendor/runit/README.md
vendored
Normal file
@ -0,0 +1,390 @@
|
||||
# runit Cookbook
|
||||
|
||||
[](https://travis-ci.org/chef-cookbooks/runit) [](https://supermarket.chef.io/cookbooks/runit)
|
||||
|
||||
Installs runit and provides the `runit_service` service resource for managing processes (services) under runit.
|
||||
|
||||
This cookbook does not use runit to replace system init, nor are there plans to do so.
|
||||
|
||||
For more information about runit:
|
||||
|
||||
- <http://smarden.org/runit/>
|
||||
|
||||
NOTE: The 5.0 release of this cookbook requires the ChefSpec which shipped in the later versions of ChefDK 3. If you use this cookbook along with ChefSpec in your environment then you will need to upgrade to the latest version of ChefDK / Workstation to prevent spec failures.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Platforms
|
||||
|
||||
- Debian/Ubuntu
|
||||
- RHEL and derivatives
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 14.0+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
- packagecloud (for RHEL)
|
||||
- yum-epel (for RHEL)
|
||||
|
||||
## Attributes
|
||||
|
||||
- `node['runit']['prefer_local_yum']` - If `true`, assumes that a `runit` package is available on an already configured local yum repository. By default, the recipe installs the `runit` package from a Package Cloud repository (see below). This is set to the value of `node['runit']['use_package_from_yum']` for backwards compatibility, but otherwise defaults to `false`.
|
||||
|
||||
## Recipes
|
||||
|
||||
### default
|
||||
|
||||
The default recipe installs runit and starts `runsvdir` to supervise the services in runit's service directory (e.g., `/etc/service`).
|
||||
|
||||
On RHEL-family systems, it will install the runit RPM using [Ian Meyer's Package Cloud repository](https://packagecloud.io/imeyer/runit) for runit. This replaces the previous functionality where the RPM was build using his [runit RPM SPEC](https://github.com/imeyer/runit-rpm). However, if the attribute `node['runit']['prefer_local_yum']` is set to `true`, the packagecloud repository creation will be skipped and it is assumed that a `runit` package is available on an otherwise configured (outside this cookbook) local repository.
|
||||
|
||||
On Debian family systems, the runit packages are maintained by the runit author, Gerrit Pape, and the recipe will use that for installation.
|
||||
|
||||
## Resource
|
||||
|
||||
This cookbook has a resource, `runit_service`, for managing services under runit.
|
||||
|
||||
### Actions
|
||||
|
||||
- **enable** - enables the service, creating the required run scripts and symlinks. This is the default action.
|
||||
- **start** - starts the service with `sv start`
|
||||
- **stop** - stops the service with `sv stop`
|
||||
- **disable** - stops the service with `sv down` and removes the service symlink
|
||||
- **create** - create the service directory, but don't enable the service with symlink
|
||||
- **restart** - restarts the service with `sv restart`
|
||||
- **reload** - reloads the service with `sv force-reload`
|
||||
- **reload_log** - reloads the service's log service
|
||||
- **once** - starts the service with `sv once`.
|
||||
- **hup** - sends the `HUP` signal to the service with `sv hup`
|
||||
- **cont** - sends the `CONT` signal to the service
|
||||
- **term** - sends the `TERM` signal to the service
|
||||
- **kill** - sends the `KILL` signal to the service
|
||||
- **up** - starts the service with `sv up`
|
||||
- **down** - downs the service with `sv down`
|
||||
- **usr1** - sends the `USR1` signal to the service with `sv 1`
|
||||
- **usr2** - sends the `USR2` signal to the service with `sv 2`
|
||||
|
||||
Service management actions are taken with runit's "`sv`" program.
|
||||
|
||||
Read the `sv(8)` [man page](http://smarden.org/runit/sv.8.html) for more information on the `sv` program.
|
||||
|
||||
### Properties
|
||||
|
||||
The first three properties, `sv_dir`, `service_dir`, and `sv_bin` will attempt to use the legacy node attributes, and fall back to hardcoded default values that match the settings used on Debian platform systems.
|
||||
|
||||
Many of these properties are only used in the `:enable` action.
|
||||
|
||||
- **sv_dir** - The base "service directory" for the services managed by the resource. By default, this will attempt to use the `node['runit']['sv_dir']` attribute, and falls back to `/etc/sv`.
|
||||
- **service_dir** - The directory where services are symlinked to be supervised by `runsvdir`. By default, this will attempt to use the `node['runit']['service_dir']` attribute, and falls back to `/etc/service`.
|
||||
- **lsb_init_dir** - The directory where an LSB-compliant init script interface will be created. By default, this will attempt to use the `node['runit']['lsb_init_dir']` attribute, and falls back to `/etc/init.d`.
|
||||
- **sv_bin** - The path to the `sv` program binary. This will attempt to use the `node['runit']['sv_bin']` attribute, and falls back to `/usr/bin/sv`.
|
||||
- **service_name** - _Name attribute_. The name of the service. This will be used in the directory of the managed service in the `sv_dir` and `service_dir`.
|
||||
- **sv_timeout** - Override the default `sv` timeout of 7 seconds.
|
||||
- **sv_verbose** - Whether to enable `sv` verbose mode. Default is `false`.
|
||||
- **sv_templates** - If true, the `:enable` action will create the service directory with the appropriate templates. Default is `true`. Set this to `false` if the service has a package that provides its own service directory. See **Usage** examples.
|
||||
- **options** - DEPRECATED - Options passed as variables to templates, for compatibility with legacy runit service definition. Default is an empty hash.
|
||||
- **env** - A hash of environment variables with their values as content used in the service's `env` directory. Default is an empty hash. When this hash is non-empty, the contents of the runit service's `env` directory will be managed by Chef in order to conform to the declared state.
|
||||
- **log** - Whether to start the service's logger with svlogd, requires a template `sv-service_name-log-run.erb` to configure the log's run script. Default is true.
|
||||
- **default_logger** - Whether a default `log/run` script should be set up. If true, the default content of the run script will use `svlogd` to write logs to `/var/log/service_name`. Default is false.
|
||||
- **log_dir** - The directory where the `svlogd` log service will run. Used when `default_logger` is `true`. Default is `/var/log/service_name`
|
||||
- **log_flags** - The flags to pass to the `svlogd` command. Used when `default_logger` is `true`. Default is `-tt`
|
||||
- **log_size** - The maximum size a log file can grow to before it is automatically rotated. See svlogd(8) for the default value.
|
||||
- **log_num** - The maximum number of log files that will be retained after rotation. See svlogd(8) for the default value.
|
||||
- **log_min** - The minimum number of log files that will be retained after rotation (if svlogd cannot create a new file and the minimum has not been reached, it will block). Default is no minimum.
|
||||
- **log_timeout** - The maximum age a log file can get to before it is automatically rotated, whether it has reached `log_size` or not. Default is no timeout.
|
||||
- **log_processor** - A string containing a path to a program that rotated log files will be fed through. See the **PROCESSOR** section of svlogd(8) for details. Default is no processor.
|
||||
- **log_socket** - An string containing an IP:port pair identifying a UDP socket that log lines will be copied to. Default is none.
|
||||
- **log_prefix** - A string that will be prepended to each line as it is logged. Default is no prefix.
|
||||
- **log_config_append** - A string containing optional additional lines to add to the log service configuration. See svlogd(8) for more details.
|
||||
- **cookbook** - A cookbook where templates are located instead of where the resource is used. Applies for all the templates in the `enable` action.
|
||||
- **check** - whether the service has a check script, requires a template `sv-service_name-check.erb`
|
||||
- **finish** - whether the service has a finish script, requires a template `sv-service_name-finish.erb`
|
||||
- **control** - An array of signals to customize control of the service, see [runsv man page](http://smarden.org/runit/runsv.8.html) on how to use this. This requires that each template be created with the name `sv-service_name-signal.erb`.
|
||||
- **supervisor_owner** - the user that should be allowed to control this service, see [runsv faq](http://smarden.org/runit/faq.html#user)
|
||||
- **supervisor_group** - the group that should be allowed to control this service, see [runsv faq](http://smarden.org/runit/faq.html#user)
|
||||
- **owner** - user that should own the templates created to enable the service
|
||||
- **group** - group that should own the templates created to enable the service
|
||||
- **run_template_name** - alternate filename of the run run script to use replacing `service_name`.
|
||||
- **log_template_name** - alternate filename of the log run script to use replacing `service_name`.
|
||||
- **check_script_template_name** - alternate filename of the check script to use, replacing `service_name`.
|
||||
- **finish_script_template_name** - alternate filename of the finish script to use, replacing `service_name`.
|
||||
- **control_template_names** - a hash of control signals (see _control_ above) and their alternate template name(s) replacing `service_name`.
|
||||
- **status_command** - The command used to check the status of the service to see if it is enabled/running (if it's running, it's enabled). This hardcodes the location of the sv program to `/usr/bin/sv` due to the aforementioned cookbook load order.
|
||||
- **restart_on_update** - Whether the service should be restarted when the run script is updated. Defaults to `true`. Set to `false` if the service shouldn't be restarted when the run script is updated.
|
||||
- **start_down** - Set the default state of the runit service to 'down' by creating `<sv_dir>/down` file. Defaults to `false`. Services using `start_down` will not be notified to restart when their run script is updated.
|
||||
- **delete_downfile** - Delete previously created `<sv_dir>/down` file
|
||||
|
||||
Unlike previous versions of the cookbook using the `runit_service` definition, the `runit_service` resource can be notified. See **Usage** examples below.
|
||||
|
||||
## Usage
|
||||
|
||||
To get runit installed on supported platforms, use `recipe[runit]`. Once it is installed, use the `runit_service` resource to set up services to be managed by runit.
|
||||
|
||||
In order to use the `runit_service` resource in your cookbook(s), each service managed will also need to have `sv-service_name-run.erb` and `sv-service_name-log-run.erb` templates created. If the `log` property is false, the log run script isn't created. If the `log` property is true, and `default_logger` is also true, the log run script will be created with the default content:
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
exec svlogd -tt /var/log/service_name
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
These are example use cases of the `runit_service` resource described above. There are others in the `runit_test` cookbook that is included in the [git repository](https://github.com/hw-cookbooks/runit).
|
||||
|
||||
**Default Example**
|
||||
|
||||
This example uses all the defaults in the `:enable` action to set up the service.
|
||||
|
||||
We'll set up `chef-client` to run as a service under runit, such as is done in the `chef-client` cookbook. This example will be more simple than in that cookbook. First, create the required run template, `chef-client/templates/default/sv-chef-client-run.erb`.
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
exec /usr/bin/env chef-client -i 1800 -s 30
|
||||
```
|
||||
|
||||
Then create the required log/run template, `chef-client/templates/default/sv-chef-client-log-run.erb`.
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
exec svlogd -tt ./main
|
||||
```
|
||||
|
||||
**Note** This will cause output of the running process to go to `/etc/sv/chef-client/log/main/current`. Some people may not like this, see the following example. This is preserved for compatibility reasons.
|
||||
|
||||
Finally, set up the service in the recipe with:
|
||||
|
||||
```ruby
|
||||
runit_service "chef-client"
|
||||
```
|
||||
|
||||
**Default Logger Example**
|
||||
|
||||
To use a default logger with svlogd which will log to `/var/log/chef-client/current`, instead, use the `default_logger` option.
|
||||
|
||||
```ruby
|
||||
runit_service "chef-client" do
|
||||
default_logger true
|
||||
end
|
||||
```
|
||||
|
||||
**No Log Service**
|
||||
|
||||
If there isn't an appendant log service, set `log` to false, and the log/run script won't be created.
|
||||
|
||||
```ruby
|
||||
runit_service "no-svlog" do
|
||||
log false
|
||||
end
|
||||
```
|
||||
|
||||
**Check Script**
|
||||
|
||||
To create a service that has a check script in its service directory, set the `check` property to `true`, and create a `sv-checker-check.erb` template.
|
||||
|
||||
```ruby
|
||||
runit_service "checker" do
|
||||
check true
|
||||
end
|
||||
```
|
||||
|
||||
This will create `/etc/sv/checker/check`.
|
||||
|
||||
**Finish Script**
|
||||
|
||||
To create a service that has a finish script in its service directory, set the `finish` property to `true`, and create a `sv-finisher-finish.erb` template.
|
||||
|
||||
```ruby
|
||||
runit_service "finisher" do
|
||||
finish true
|
||||
end
|
||||
```
|
||||
|
||||
This will create `/etc/sv/finisher/finish`.
|
||||
|
||||
**Alternate service directory**
|
||||
|
||||
If the service directory for the managed service isn't the `sv_dir` (`/etc/sv`), then specify it:
|
||||
|
||||
```ruby
|
||||
runit_service "custom_service" do
|
||||
sv_dir "/etc/custom_service/runit"
|
||||
end
|
||||
```
|
||||
|
||||
**No Service Directory**
|
||||
|
||||
If the service to manage has a package that provides its service directory, such as `git-daemon` on Debian systems, set `sv_templates` to false.
|
||||
|
||||
```ruby
|
||||
package "git-daemon-run"
|
||||
|
||||
runit_service "git-daemon" do
|
||||
sv_templates false
|
||||
end
|
||||
```
|
||||
|
||||
This will create the service symlink in `/etc/service`, but it will not manage any templates in the service directory.
|
||||
|
||||
**User Controlled Services**
|
||||
|
||||
To set up services controlled by a non-privileged user, we follow the recommended configuration in the [runit documentation](http://smarden.org/runit/faq.html#user) (Is it possible to allow a user other than root to control a service?).
|
||||
|
||||
Suppose the user's name is floyd, and floyd wants to run floyds-app. Assuming that the floyd user and group are already managed with Chef, create a `runsvdir-floyd` runit_service.
|
||||
|
||||
```ruby
|
||||
runit_service "runsvdir-floyd"
|
||||
```
|
||||
|
||||
Create the `sv-runsvdir-floyd-log-run.erb` template, or add `log false`. Also create the `sv-runsvdir-floyd-run.erb` with the following content:
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
exec chpst -ufloyd runsvdir /home/floyd/service
|
||||
```
|
||||
|
||||
Next, create the `runit_service` resource for floyd's app:
|
||||
|
||||
```ruby
|
||||
runit_service "floyds-app" do
|
||||
sv_dir "/home/floyd/sv"
|
||||
service_dir "/home/floyd/service"
|
||||
owner "floyd"
|
||||
group "floyd"
|
||||
end
|
||||
```
|
||||
|
||||
And now floyd can manage the service with sv:
|
||||
|
||||
```text
|
||||
$ id
|
||||
uid=1000(floyd) gid=1001(floyd) groups=1001(floyd)
|
||||
$ sv stop /home/floyd/service/floyds-app/
|
||||
ok: down: /home/floyd/service/floyds-app/: 0s, normally up
|
||||
$ sv start /home/floyd/service/floyds-app/
|
||||
ok: run: /home/floyd/service/floyds-app/: (pid 5287) 0s
|
||||
$ sv status /home/floyd/service/floyds-app/
|
||||
run: /home/floyd/service/floyds-app/: (pid 5287) 13s; run: log: (pid 4691) 726s
|
||||
```
|
||||
|
||||
**Options**
|
||||
|
||||
Next, let's set up memcached under runit with some additional options using the `options` property. First, the `memcached/templates/default/sv-memcached-run.erb` template:
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
exec chpst -u <%= @options[:user] %> /usr/bin/memcached -v -m <%= @options[:memory] %> -p <%= @options[:port] %>
|
||||
```
|
||||
|
||||
Note that the script uses `chpst` (which comes with runit) to set the user option, then starts memcached on the specified memory and port (see below).
|
||||
|
||||
The log/run template, `memcached/templates/default/sv-memcached-log-run.erb`:
|
||||
|
||||
```bash
|
||||
#!/bin/sh
|
||||
exec svlogd -tt ./main
|
||||
```
|
||||
|
||||
Finally, the `runit_service` in our recipe:
|
||||
|
||||
```ruby
|
||||
runit_service "memcached" do
|
||||
options({
|
||||
:memory => node[:memcached][:memory],
|
||||
:port => node[:memcached][:port],
|
||||
:user => node[:memcached][:user]
|
||||
}.merge(params))
|
||||
end
|
||||
```
|
||||
|
||||
This is where the user, port and memory options used in the run template are used.
|
||||
|
||||
**Notifying Runit Services**
|
||||
|
||||
In previous versions of this cookbook where the definition was used, it created a `service` resource that could be notified. With the `runit_service` resource, recipes need to use the full resource name.
|
||||
|
||||
For example:
|
||||
|
||||
```ruby
|
||||
runit_service "my-service"
|
||||
|
||||
template "/etc/my-service.conf" do
|
||||
notifies :restart, "runit_service[my-service]"
|
||||
end
|
||||
```
|
||||
|
||||
Because the resource implements actions for various commands that `sv` can send to the service, any of those actions could be used for notification. For example, `chef-client` supports triggering a Chef run with a USR1 signal.
|
||||
|
||||
```ruby
|
||||
template "/tmp/chef-notifier" do
|
||||
notifies :usr1, "runit_service[chef-client]"
|
||||
end
|
||||
```
|
||||
|
||||
For older implementations of services that used `runit_service` as a definition, but may support alternate service styles, use a conditional, such as based on an attribute:
|
||||
|
||||
```ruby
|
||||
service_to_notify = case node['nginx']['init_style']
|
||||
when "runit"
|
||||
"runit_service[nginx]"
|
||||
else
|
||||
"service[nginx]"
|
||||
end
|
||||
|
||||
template "/etc/nginx/nginx.conf" do
|
||||
notifies :restart, service_to_notify
|
||||
end
|
||||
```
|
||||
|
||||
**More Examples**
|
||||
|
||||
For more examples, see the `runit_test` cookbook's `service` recipe in the [git repository](https://github.com/hw-cookbooks/runit).
|
||||
|
||||
## Development
|
||||
|
||||
You may use test kitchen with either the vagrant or docker drivers to run integration tests.
|
||||
|
||||
**Note:** When using the docker driver please ensure that the container you are using has a working init system, as runit expects to be started by init. In some cases, systemd may need to be run in privileged mode.
|
||||
|
||||
For instance, for ubuntu with upstart:
|
||||
|
||||
```
|
||||
driver_config:
|
||||
image: ubuntu-upstart:14.04
|
||||
run_command: /sbin/init
|
||||
```
|
||||
|
||||
For redhat derivatives:
|
||||
|
||||
```
|
||||
driver_config:
|
||||
image: dockerhub/image-with-systemd
|
||||
run_command: /usr/sbin/init
|
||||
privileged: true
|
||||
```
|
||||
|
||||
## License & Authors
|
||||
|
||||
- Author:: Adam Jacob [adam@chef.io](mailto:adam@chef.io)
|
||||
- Author:: Joshua Timberman [joshua@chef.io](mailto:joshua@chef.io)
|
||||
- Author:: Sean OMeara [sean@sean.io](mailto:sean@sean.io)
|
||||
|
||||
```text
|
||||
Copyright:: 2008-2019, Chef Software, Inc
|
||||
|
||||
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.
|
||||
```
|
20
ops/cookbooks/vendor/runit/attributes/default.rb
vendored
Normal file
20
ops/cookbooks/vendor/runit/attributes/default.rb
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Cookbook:: runit
|
||||
# Attribute:: File:: sv_bin
|
||||
#
|
||||
# Copyright:: 2008-2019, Chef Software Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
default['runit']['prefer_local_yum'] = node['runit']['use_package_from_yum'] || false
|
1
ops/cookbooks/vendor/runit/files/runit.seed
vendored
Normal file
1
ops/cookbooks/vendor/runit/files/runit.seed
vendored
Normal file
@ -0,0 +1 @@
|
||||
runit runit/signalinit boolean true
|
183
ops/cookbooks/vendor/runit/libraries/helpers.rb
vendored
Normal file
183
ops/cookbooks/vendor/runit/libraries/helpers.rb
vendored
Normal file
@ -0,0 +1,183 @@
|
||||
#
|
||||
# Cookbook:: runit
|
||||
# Library:: helpers
|
||||
#
|
||||
# Author:: Joshua Timberman <joshua@chef.io>
|
||||
# Author:: Sean OMeara <sean@sean.io>
|
||||
# Copyright:: 2008-2019, Chef Software, Inc. <legal@chef.io>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
module RunitCookbook
|
||||
module Helpers
|
||||
# include Chef::Mixin::ShellOut if it is not already included in the calling class
|
||||
def self.included(klass)
|
||||
klass.class_eval { include Chef::Mixin::ShellOut } unless klass.ancestors.include?(Chef::Mixin::ShellOut)
|
||||
end
|
||||
|
||||
def down_file
|
||||
::File.join(sv_dir_name, 'down')
|
||||
end
|
||||
|
||||
def env_dir
|
||||
::File.join(sv_dir_name, 'env')
|
||||
end
|
||||
|
||||
def extra_env_files?
|
||||
files = []
|
||||
Dir.glob(::File.join(sv_dir_name, 'env', '*')).each do |f|
|
||||
files << File.basename(f)
|
||||
end
|
||||
return true if files.sort != new_resource.env.keys.sort
|
||||
false
|
||||
end
|
||||
|
||||
def delete_extra_env_files
|
||||
Dir.glob(::File.join(sv_dir_name, 'env', '*')).each do |f|
|
||||
unless new_resource.env.key?(File.basename(f))
|
||||
File.unlink(f)
|
||||
Chef::Log.info("removing file #{f}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def wait_for_service
|
||||
raise 'Runit does not appear to be installed. Include runit::default before using the resource!' unless binary_exists?
|
||||
|
||||
sleep 1 until ::FileTest.pipe?(::File.join(service_dir_name, 'supervise', 'ok'))
|
||||
|
||||
if new_resource.log
|
||||
sleep 1 until ::FileTest.pipe?(::File.join(service_dir_name, 'log', 'supervise', 'ok'))
|
||||
end
|
||||
end
|
||||
|
||||
def runit_send_signal(signal, friendly_name = nil)
|
||||
friendly_name ||= signal
|
||||
converge_by("send #{friendly_name} to #{new_resource}") do
|
||||
safe_sv_shellout!("#{sv_args}#{signal} #{service_dir_name}")
|
||||
Chef::Log.info("#{new_resource} sent #{friendly_name}")
|
||||
end
|
||||
end
|
||||
|
||||
def running?
|
||||
cmd = safe_sv_shellout("#{sv_args}status #{service_dir_name}", returns: [0, 100])
|
||||
!cmd.error? && cmd.stdout =~ /^run:/
|
||||
end
|
||||
|
||||
def log_running?
|
||||
cmd = safe_sv_shellout("#{sv_args}status #{::File.join(service_dir_name, 'log')}", returns: [0, 100])
|
||||
!cmd.error? && cmd.stdout =~ /^run:/
|
||||
end
|
||||
|
||||
def enabled?
|
||||
::File.exist?(::File.join(service_dir_name, 'run'))
|
||||
end
|
||||
|
||||
def log_service_name
|
||||
::File.join(new_resource.service_name, 'log')
|
||||
end
|
||||
|
||||
def sv_dir_name
|
||||
::File.join(new_resource.sv_dir, new_resource.service_name)
|
||||
end
|
||||
|
||||
def sv_args
|
||||
sv_args = ''
|
||||
sv_args += "-w #{new_resource.sv_timeout} " unless new_resource.sv_timeout.nil?
|
||||
sv_args += '-v ' if new_resource.sv_verbose
|
||||
sv_args
|
||||
end
|
||||
|
||||
def service_dir_name
|
||||
::File.join(new_resource.service_dir, new_resource.service_name)
|
||||
end
|
||||
|
||||
def log_dir_name
|
||||
::File.join(new_resource.service_dir, new_resource.service_name, log)
|
||||
end
|
||||
|
||||
def binary_exists?
|
||||
begin
|
||||
Chef::Log.debug("Checking to see if the runit binary exists by running #{new_resource.sv_bin}")
|
||||
shell_out!(new_resource.sv_bin.to_s, returns: [0, 100])
|
||||
rescue Errno::ENOENT
|
||||
Chef::Log.debug("Failed to return 0 or 100 running #{new_resource.sv_bin}")
|
||||
return false
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def safe_sv_shellout(command, options = {})
|
||||
begin
|
||||
Chef::Log.debug("Attempting to run runit command: #{new_resource.sv_bin} #{command}")
|
||||
cmd = shell_out("#{new_resource.sv_bin} #{command}", options)
|
||||
rescue Errno::ENOENT
|
||||
if binary_exists?
|
||||
raise # Some other cause
|
||||
else
|
||||
raise 'Runit does not appear to be installed. You must install runit before using the runit_service resource!'
|
||||
end
|
||||
end
|
||||
cmd
|
||||
end
|
||||
|
||||
def safe_sv_shellout!(command, options = {})
|
||||
safe_sv_shellout(command, options).tap(&:error!)
|
||||
end
|
||||
|
||||
def disable_service
|
||||
Chef::Log.debug("Attempting to disable runit service with: #{new_resource.sv_bin} #{sv_args}down #{service_dir_name}")
|
||||
shell_out("#{new_resource.sv_bin} #{sv_args}down #{service_dir_name}")
|
||||
FileUtils.rm(service_dir_name)
|
||||
|
||||
# per the documentation, a service should be removed from supervision
|
||||
# within 5 seconds of removing the service dir symlink, so we'll sleep for 6.
|
||||
# otherwise, runit recreates the 'ok' named pipe too quickly
|
||||
Chef::Log.debug('Sleeping 6 seconds to allow the disable to take effect')
|
||||
sleep(6)
|
||||
# runit will recreate the supervise directory and
|
||||
# pipes when the service is reenabled
|
||||
Chef::Log.debug("Removing #{::File.join(sv_dir_name, 'supervise', 'ok')}")
|
||||
FileUtils.rm(::File.join(sv_dir_name, 'supervise', 'ok'))
|
||||
end
|
||||
|
||||
def start_service
|
||||
safe_sv_shellout!("#{sv_args}start #{service_dir_name}")
|
||||
end
|
||||
|
||||
def stop_service
|
||||
safe_sv_shellout!("#{sv_args}stop #{service_dir_name}")
|
||||
end
|
||||
|
||||
def restart_service
|
||||
safe_sv_shellout!("#{sv_args}restart #{service_dir_name}")
|
||||
end
|
||||
|
||||
def restart_log_service
|
||||
safe_sv_shellout!("#{sv_args}restart #{::File.join(service_dir_name, 'log')}")
|
||||
end
|
||||
|
||||
def reload_service
|
||||
safe_sv_shellout!("#{sv_args}force-reload #{service_dir_name}")
|
||||
end
|
||||
|
||||
def reload_log_service
|
||||
if log_running?
|
||||
safe_sv_shellout!("#{sv_args}force-reload #{::File.join(service_dir_name, 'log')}")
|
||||
else
|
||||
Chef::Log.debug('Logging not running so doing nothing')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
368
ops/cookbooks/vendor/runit/libraries/provider_runit_service.rb
vendored
Normal file
368
ops/cookbooks/vendor/runit/libraries/provider_runit_service.rb
vendored
Normal file
@ -0,0 +1,368 @@
|
||||
#
|
||||
# Cookbook:: runit
|
||||
# Provider:: runit_service
|
||||
#
|
||||
# Author:: Joshua Timberman <jtimberman@chef.io>
|
||||
# Author:: Sean OMeara <sean@sean.io>
|
||||
# Copyright:: 2011-2019, Chef Software Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
class Chef
|
||||
class Provider
|
||||
class RunitService < Chef::Provider::LWRPBase
|
||||
provides :runit_service
|
||||
|
||||
unless defined?(VALID_SIGNALS)
|
||||
# Mapping of valid signals with optional friendly name
|
||||
VALID_SIGNALS = Mash.new(
|
||||
:down => nil,
|
||||
:hup => nil,
|
||||
:int => nil,
|
||||
:term => nil,
|
||||
:kill => nil,
|
||||
:quit => nil,
|
||||
:up => nil,
|
||||
:once => nil,
|
||||
:cont => nil,
|
||||
1 => :usr1,
|
||||
2 => :usr2
|
||||
)
|
||||
end
|
||||
|
||||
# Mix in helpers from libraries/helpers.rb
|
||||
include RunitCookbook::Helpers
|
||||
|
||||
# actions
|
||||
action :create do
|
||||
ruby_block 'restart_service' do
|
||||
block do
|
||||
previously_enabled = enabled?
|
||||
action_enable
|
||||
|
||||
# Only restart the service if it was previously enabled. If the service was disabled
|
||||
# or not running, then the enable action will start the service, and it's unnecessary
|
||||
# to restart the service again.
|
||||
restart_service if previously_enabled
|
||||
end
|
||||
action :nothing
|
||||
only_if { new_resource.restart_on_update && !new_resource.start_down }
|
||||
end
|
||||
|
||||
ruby_block 'restart_log_service' do
|
||||
block do
|
||||
action_enable
|
||||
restart_log_service
|
||||
end
|
||||
action :nothing
|
||||
only_if { new_resource.restart_on_update && !new_resource.start_down }
|
||||
end
|
||||
|
||||
# sv_templates
|
||||
if new_resource.sv_templates
|
||||
directory sv_dir_name do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
template ::File.join(sv_dir_name, 'run') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
source "sv-#{new_resource.run_template_name}-run.erb"
|
||||
cookbook new_resource.cookbook
|
||||
mode '0755'
|
||||
variables(options: new_resource.options)
|
||||
action :create
|
||||
notifies :run, 'ruby_block[restart_service]', :delayed
|
||||
end
|
||||
|
||||
# log stuff
|
||||
if new_resource.log
|
||||
directory ::File.join(sv_dir_name, 'log') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
directory ::File.join(sv_dir_name, 'log', 'main') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
directory new_resource.log_dir do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
recursive true
|
||||
action :create
|
||||
end
|
||||
|
||||
template ::File.join(sv_dir_name, 'log', 'config') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0644'
|
||||
cookbook 'runit'
|
||||
source 'log-config.erb'
|
||||
variables(config: new_resource)
|
||||
notifies :run, 'ruby_block[restart_log_service]', :delayed
|
||||
action :create
|
||||
end
|
||||
|
||||
link ::File.join(new_resource.log_dir, 'config') do
|
||||
to ::File.join(sv_dir_name, 'log', 'config')
|
||||
end
|
||||
|
||||
if new_resource.default_logger
|
||||
template ::File.join(sv_dir_name, 'log', 'run') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
cookbook 'runit'
|
||||
source 'log-run.erb'
|
||||
variables(config: new_resource)
|
||||
notifies :run, 'ruby_block[restart_log_service]', :delayed
|
||||
action :create
|
||||
end
|
||||
else
|
||||
template ::File.join(sv_dir_name, 'log', 'run') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
source "sv-#{new_resource.log_template_name}-log-run.erb"
|
||||
cookbook new_resource.cookbook
|
||||
variables(options: new_resource.options)
|
||||
action :create
|
||||
notifies :run, 'ruby_block[restart_log_service]', :delayed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# environment stuff
|
||||
directory ::File.join(sv_dir_name, 'env') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
action :create
|
||||
end
|
||||
|
||||
new_resource.env.map do |var, value|
|
||||
file ::File.join(sv_dir_name, 'env', var) do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
content value
|
||||
sensitive true
|
||||
mode '0640'
|
||||
action :create
|
||||
notifies :run, 'ruby_block[restart_service]', :delayed
|
||||
end
|
||||
end
|
||||
|
||||
ruby_block "Delete unmanaged env files for #{new_resource.name} service" do
|
||||
block { delete_extra_env_files }
|
||||
only_if { extra_env_files? }
|
||||
not_if { new_resource.env.empty? }
|
||||
action :run
|
||||
notifies :run, 'ruby_block[restart_service]', :delayed
|
||||
end
|
||||
|
||||
template ::File.join(sv_dir_name, 'check') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
cookbook new_resource.cookbook
|
||||
source "sv-#{new_resource.check_script_template_name}-check.erb"
|
||||
variables(options: new_resource.options)
|
||||
action :create
|
||||
only_if { new_resource.check }
|
||||
end
|
||||
|
||||
template ::File.join(sv_dir_name, 'finish') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
source "sv-#{new_resource.finish_script_template_name}-finish.erb"
|
||||
cookbook new_resource.cookbook
|
||||
variables(options: new_resource.options) if new_resource.options.respond_to?(:has_key?)
|
||||
action :create
|
||||
only_if { new_resource.finish }
|
||||
end
|
||||
|
||||
directory ::File.join(sv_dir_name, 'control') do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
action :create
|
||||
end
|
||||
|
||||
new_resource.control.map do |signal|
|
||||
template ::File.join(sv_dir_name, 'control', signal) do
|
||||
owner new_resource.owner unless new_resource.owner.nil?
|
||||
group new_resource.group unless new_resource.group.nil?
|
||||
mode '0755'
|
||||
source "sv-#{new_resource.control_template_names[signal]}-#{signal}.erb"
|
||||
cookbook new_resource.cookbook
|
||||
variables(options: new_resource.options)
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
# lsb_init
|
||||
if platform?('debian','ubuntu') && !new_resource.use_init_script_sv_link
|
||||
ruby_block "unlink #{::File.join(new_resource.lsb_init_dir, new_resource.service_name)}" do
|
||||
block { ::File.unlink(::File.join(new_resource.lsb_init_dir, new_resource.service_name).to_s) }
|
||||
only_if { ::File.symlink?(::File.join(new_resource.lsb_init_dir, new_resource.service_name).to_s) }
|
||||
end
|
||||
|
||||
template ::File.join(new_resource.lsb_init_dir, new_resource.service_name) do
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0755'
|
||||
cookbook 'runit'
|
||||
source 'init.d.erb'
|
||||
variables(
|
||||
name: new_resource.service_name,
|
||||
sv_bin: new_resource.sv_bin,
|
||||
sv_args: sv_args,
|
||||
init_dir: ::File.join(new_resource.lsb_init_dir, '')
|
||||
)
|
||||
action :create
|
||||
end
|
||||
else
|
||||
link ::File.join(new_resource.lsb_init_dir, new_resource.service_name) do
|
||||
to new_resource.sv_bin
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
# Create/Delete service down file
|
||||
# To prevent unexpected behavior, require users to explicitly set
|
||||
# delete_downfile to remove any down file that may already exist
|
||||
df_action = :nothing
|
||||
if new_resource.start_down
|
||||
df_action = :create
|
||||
elsif new_resource.delete_downfile
|
||||
df_action = :delete
|
||||
end
|
||||
|
||||
file down_file do
|
||||
mode '0644'
|
||||
backup false
|
||||
content '# File created and managed by chef!'
|
||||
action df_action
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :disable do
|
||||
ruby_block "disable #{new_resource.service_name}" do
|
||||
block { disable_service }
|
||||
only_if { enabled? }
|
||||
end
|
||||
end
|
||||
|
||||
action :enable do
|
||||
action_create
|
||||
|
||||
directory new_resource.service_dir
|
||||
|
||||
link service_dir_name.to_s do
|
||||
to sv_dir_name
|
||||
action :create
|
||||
end
|
||||
|
||||
ruby_block "wait for #{new_resource.service_name} service socket" do
|
||||
block do
|
||||
wait_for_service
|
||||
end
|
||||
action :run
|
||||
end
|
||||
|
||||
# Support supervisor owner and groups http://smarden.org/runit/faq.html#user
|
||||
if new_resource.supervisor_owner || new_resource.supervisor_group
|
||||
directory ::File.join(service_dir_name, 'supervise') do
|
||||
mode '0755'
|
||||
action :create
|
||||
end
|
||||
%w(ok status control).each do |target|
|
||||
file ::File.join(service_dir_name, 'supervise', target) do
|
||||
owner new_resource.supervisor_owner || 'root'
|
||||
group new_resource.supervisor_group || 'root'
|
||||
action :touch
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# signals
|
||||
VALID_SIGNALS.each do |signal, signal_name|
|
||||
action(signal_name || signal) do
|
||||
if running?
|
||||
Chef::Log.info "#{new_resource} signalled (#{(signal_name || signal).to_s.upcase})"
|
||||
runit_send_signal(signal, signal_name)
|
||||
else
|
||||
Chef::Log.debug "#{new_resource} not running - nothing to do"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
restart_service
|
||||
end
|
||||
|
||||
action :start do
|
||||
if running?
|
||||
Chef::Log.debug "#{new_resource} already running - nothing to do"
|
||||
else
|
||||
start_service
|
||||
Chef::Log.info "#{new_resource} started"
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
if running?
|
||||
stop_service
|
||||
Chef::Log.info "#{new_resource} stopped"
|
||||
else
|
||||
Chef::Log.debug "#{new_resource} already stopped - nothing to do"
|
||||
end
|
||||
end
|
||||
|
||||
action :reload do
|
||||
if running?
|
||||
reload_service
|
||||
Chef::Log.info "#{new_resource} reloaded"
|
||||
else
|
||||
Chef::Log.debug "#{new_resource} not running - nothing to do"
|
||||
end
|
||||
end
|
||||
|
||||
action :status do
|
||||
running?
|
||||
end
|
||||
|
||||
action :reload_log do
|
||||
converge_by('reload log service') do
|
||||
reload_log_service
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
114
ops/cookbooks/vendor/runit/libraries/resource_runit_service.rb
vendored
Normal file
114
ops/cookbooks/vendor/runit/libraries/resource_runit_service.rb
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
#
|
||||
# Cookbook:: runit
|
||||
# resource:: runit_service
|
||||
#
|
||||
# Author:: Joshua Timberman <jtimberman@chef.io>
|
||||
# Copyright:: 2011-2019, Chef Software Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
require 'chef/resource'
|
||||
require 'chef/resource/service'
|
||||
|
||||
class Chef
|
||||
class Resource
|
||||
# Missing top-level class documentation comment
|
||||
class RunitService < Chef::Resource::Service
|
||||
resource_name :runit_service
|
||||
|
||||
default_action :enable
|
||||
allowed_actions :nothing, :start, :stop, :enable, :disable, :restart, :reload, :status, :once, :hup, :cont, :term, :kill, :up, :down, :usr1, :usr2, :create, :reload_log
|
||||
|
||||
# For legacy reasons we allow setting these via attribute
|
||||
property :sv_bin, String, default: lazy { node['runit']['sv_bin'] || (platform_family?('debian') ? '/usr/bin/sv' : '/sbin/sv') }
|
||||
property :sv_dir, [String, FalseClass], default: lazy { node['runit']['sv_dir'] || '/etc/sv' }
|
||||
property :service_dir, String, default: lazy { node['runit']['service_dir'] || '/etc/service' }
|
||||
property :lsb_init_dir, String, default: lazy { node['runit']['lsb_init_dir'] || '/etc/init.d' }
|
||||
|
||||
property :control, Array, default: []
|
||||
property :options, Hash, default: lazy { default_options }, coerce: proc { |r| default_options.merge(r) if r.respond_to?(:merge) }
|
||||
property :env, Hash, default: {}
|
||||
property :log, [TrueClass, FalseClass], default: true
|
||||
property :cookbook, String
|
||||
property :check, [TrueClass, FalseClass], default: false
|
||||
property :start_down, [TrueClass, FalseClass], default: false
|
||||
property :delete_downfile, [TrueClass, FalseClass], default: false
|
||||
property :finish, [TrueClass, FalseClass], default: false
|
||||
property :supervisor_owner, String, regex: [Chef::Config[:user_valid_regex]]
|
||||
property :supervisor_group, String, regex: [Chef::Config[:group_valid_regex]]
|
||||
property :owner, String, regex: [Chef::Config[:user_valid_regex]]
|
||||
property :group, String, regex: [Chef::Config[:group_valid_regex]]
|
||||
property :enabled, [TrueClass, FalseClass], default: false
|
||||
property :running, [TrueClass, FalseClass], default: false
|
||||
property :default_logger, [TrueClass, FalseClass], default: false
|
||||
property :restart_on_update, [TrueClass, FalseClass], default: true
|
||||
property :run_template_name, String, default: lazy { service_name }
|
||||
property :log_template_name, String, default: lazy { service_name }
|
||||
property :check_script_template_name, String, default: lazy { service_name }
|
||||
property :finish_script_template_name, String, default: lazy { service_name }
|
||||
property :control_template_names, Hash, default: lazy { set_control_template_names }
|
||||
property :status_command, String, default: lazy { "#{sv_bin} status #{service_dir}" }
|
||||
property :sv_templates, [TrueClass, FalseClass], default: true
|
||||
property :sv_timeout, Integer
|
||||
property :sv_verbose, [TrueClass, FalseClass], default: false
|
||||
property :log_dir, String, default: lazy { ::File.join('/var/log/', service_name) }
|
||||
property :log_flags, String, default: '-tt'
|
||||
property :log_size, Integer
|
||||
property :log_num, Integer
|
||||
property :log_min, Integer
|
||||
property :log_timeout, Integer
|
||||
property :log_processor, String
|
||||
property :log_socket, [String, Hash]
|
||||
property :log_prefix, String
|
||||
property :log_config_append, String
|
||||
|
||||
# Use a link to sv instead of a full blown init script calling runit.
|
||||
# This was added for omnibus projects and probably shouldn't be used elsewhere
|
||||
property :use_init_script_sv_link, [TrueClass, FalseClass], default: false
|
||||
|
||||
alias template_name run_template_name
|
||||
|
||||
def set_control_template_names
|
||||
template_names = {}
|
||||
control.each do |signal|
|
||||
template_names[signal] ||= service_name
|
||||
end
|
||||
template_names
|
||||
end
|
||||
|
||||
# the default legacy options kept for compatibility with the definition
|
||||
#
|
||||
# @return [Hash] an empty hash if env property is set. Otherwise it's env_dir
|
||||
def default_options
|
||||
env.empty? ? {} : { env_dir: ::File.join(sv_dir, service_name, 'env') }
|
||||
end
|
||||
|
||||
def after_created
|
||||
unless run_context.nil?
|
||||
new_resource = self
|
||||
service_dir_name = ::File.join(service_dir, service_name)
|
||||
find_resource(:service, new_resource.name) do # creates if it does not exist
|
||||
provider Chef::Provider::Service::Simple
|
||||
supports new_resource.supports
|
||||
start_command "#{new_resource.sv_bin} start #{service_dir_name}"
|
||||
stop_command "#{new_resource.sv_bin} stop #{service_dir_name}"
|
||||
restart_command "#{new_resource.sv_bin} restart #{service_dir_name}"
|
||||
status_command "#{new_resource.sv_bin} status #{service_dir_name}"
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
1
ops/cookbooks/vendor/runit/metadata.json
vendored
Normal file
1
ops/cookbooks/vendor/runit/metadata.json
vendored
Normal file
File diff suppressed because one or more lines are too long
20
ops/cookbooks/vendor/runit/metadata.rb
vendored
Normal file
20
ops/cookbooks/vendor/runit/metadata.rb
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
name 'runit'
|
||||
maintainer 'Chef Software, Inc.'
|
||||
maintainer_email 'cookbooks@chef.io'
|
||||
license 'Apache-2.0'
|
||||
description 'Installs runit and provides runit_service resource'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '5.1.1'
|
||||
|
||||
recipe 'runit', 'Installs and configures runit'
|
||||
|
||||
%w(ubuntu debian centos redhat amazon scientific oracle enterpriseenterprise zlinux).each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
depends 'packagecloud'
|
||||
depends 'yum-epel'
|
||||
|
||||
source_url 'https://github.com/chef-cookbooks/runit'
|
||||
issues_url 'https://github.com/chef-cookbooks/runit/issues'
|
||||
chef_version '>= 14.0'
|
79
ops/cookbooks/vendor/runit/recipes/default.rb
vendored
Normal file
79
ops/cookbooks/vendor/runit/recipes/default.rb
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
#
|
||||
# Cookbook:: runit
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2008-2019, Chef Software, Inc.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
case node['platform_family']
|
||||
when 'rhel', 'amazon'
|
||||
|
||||
# add the necessary repos unless prefer_local_yum is set
|
||||
unless node['runit']['prefer_local_yum']
|
||||
include_recipe 'yum-epel' if node['platform_version'].to_i < 7 && platform_family?('rhel')
|
||||
|
||||
packagecloud_repo 'imeyer/runit' do
|
||||
force_os 'rhel' if platform?('oracle', 'amazon') # ~FC024
|
||||
force_dist '6' if platform?('amazon')
|
||||
force_dist '7' if platform?('amazon') && node['platform_version'].to_i == 2
|
||||
type 'rpm' if platform?('amazon')
|
||||
end
|
||||
end
|
||||
|
||||
package 'runit'
|
||||
when 'debian'
|
||||
# debian 9+ ships with runit-systemd which includes only what you need for process supervision and not
|
||||
# what is necessary for running runit as pid 1, which we don't care about.
|
||||
pv = node['platform_version']
|
||||
pkg_name = if (platform?('debian') && pv.to_i >= 9) || \
|
||||
(platform?('ubuntu') && Gem::Version.new(pv) >= Gem::Version.new('17.10'))
|
||||
'runit-systemd'
|
||||
else
|
||||
'runit'
|
||||
end
|
||||
|
||||
package pkg_name do
|
||||
action :install
|
||||
response_file 'runit.seed'
|
||||
end
|
||||
else
|
||||
raise 'The cookbook only supports Debian/RHEL based Linux distributions. If you believe further platform support is possible please open a pull request.'
|
||||
end
|
||||
|
||||
# we need to make sure we start the runit service so that runit services can be started up at boot
|
||||
# or when they fail
|
||||
plat_specific_sv_name = case node['platform_family']
|
||||
when 'debian'
|
||||
if platform?('ubuntu') && node['platform_version'].to_f < 16.04
|
||||
'runsvdir'
|
||||
else
|
||||
'runit'
|
||||
end
|
||||
when 'rhel', 'amazon'
|
||||
if node['platform_version'].to_i >= 7 && platform_family?('rhel')
|
||||
'runsvdir-start'
|
||||
elsif node['platform_version'].to_i == 2 && platform?('amazon')
|
||||
'runsvdir-start'
|
||||
else
|
||||
'runsvdir'
|
||||
end
|
||||
else
|
||||
'runsvdir'
|
||||
end
|
||||
|
||||
service plat_specific_sv_name do
|
||||
action [:start, :enable]
|
||||
# this might seem crazy, but RHEL 6 is in fact Upstart and the runit service is upstart there
|
||||
provider Chef::Provider::Service::Upstart if (platform?('amazon') && node['platform_version'].to_i != 2) || (platform_family?('rhel') && node['platform_version'].to_i == 6)
|
||||
end
|
92
ops/cookbooks/vendor/runit/templates/debian/init.d.erb
vendored
Executable file
92
ops/cookbooks/vendor/runit/templates/debian/init.d.erb
vendored
Executable file
@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: <%= @name %>
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: initscript for runit-managed <%= @name %> service
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Chef Software, Inc. <cookbooks@chef.io>
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="runit-managed <%= @name %>"
|
||||
NAME=<%= @name %>
|
||||
RUNIT=<%= @sv_bin %>
|
||||
RUNIT_ARGS="<%= @sv_args %>"
|
||||
SCRIPTNAME=<%= @init_dir %>$NAME
|
||||
|
||||
# Exit if runit is not installed
|
||||
[ -x $RUNIT ] || exit 0
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
|
||||
$RUNIT $RUNIT_ARGS start $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS stop $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
status)
|
||||
$RUNIT $RUNIT_ARGS status $NAME && exit 0 || exit $?
|
||||
;;
|
||||
reload)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS reload $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-reload)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force reloading $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-reload $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force stopping $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-stop $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-restart)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force restarting $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-restart $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-shutdown)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force shutdowning $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-shutdown $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
restart)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS restart $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
shutdown)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Shutdowning $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS shutdown $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
try-restart)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Try restarting $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS try-restart $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|force-restart|force-shutdown|force-stop|restart|shutdown|try-restart}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
|
24
ops/cookbooks/vendor/runit/templates/default/log-config.erb
vendored
Normal file
24
ops/cookbooks/vendor/runit/templates/default/log-config.erb
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<% if @config.log_size -%>
|
||||
s<%= @config.log_size %>
|
||||
<% end -%>
|
||||
<% if @config.log_num -%>
|
||||
n<%= @config.log_num %>
|
||||
<% end -%>
|
||||
<% if @config.log_min -%>
|
||||
N<%= @config.log_min %>
|
||||
<% end -%>
|
||||
<% if @config.log_timeout -%>
|
||||
t<%= @config.log_timeout %>
|
||||
<% end -%>
|
||||
<% if @config.log_processor -%>
|
||||
!<%= @config.log_processor %>
|
||||
<% end -%>
|
||||
<% if @config.log_socket -%>
|
||||
u<%= @config.log_socket %>
|
||||
<% end -%>
|
||||
<% if @config.log_prefix -%>
|
||||
p<%= @config.log_prefix %>
|
||||
<% end -%>
|
||||
<% if @config.log_config_append -%>
|
||||
<%= @config.log_config_append %>
|
||||
<% end -%>
|
2
ops/cookbooks/vendor/runit/templates/default/log-run.erb
vendored
Normal file
2
ops/cookbooks/vendor/runit/templates/default/log-run.erb
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec svlogd <%= @config.log_flags %> <%= @config.log_dir %>
|
92
ops/cookbooks/vendor/runit/templates/ubuntu/init.d.erb
vendored
Executable file
92
ops/cookbooks/vendor/runit/templates/ubuntu/init.d.erb
vendored
Executable file
@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: <%= @name %>
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start:
|
||||
# Default-Stop:
|
||||
# Short-Description: initscript for runit-managed <%= @name %> service
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Chef Software, Inc. <cookbooks@chef.io>
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="runit-managed <%= @name %>"
|
||||
NAME=<%= @name %>
|
||||
RUNIT=<%= @sv_bin %>
|
||||
RUNIT_ARGS="<%= @sv_args %>"
|
||||
SCRIPTNAME=<%= @init_dir %>$NAME
|
||||
|
||||
# Exit if runit is not installed
|
||||
[ -x $RUNIT ] || exit 0
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
|
||||
$RUNIT $RUNIT_ARGS start $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS stop $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
status)
|
||||
$RUNIT $RUNIT_ARGS status $NAME && exit 0 || exit $?
|
||||
;;
|
||||
reload)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS reload $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-reload)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force reloading $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-reload $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force stopping $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-stop $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-restart)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force restarting $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-restart $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
force-shutdown)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Force shutdowning $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS force-shutdown $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
restart)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS restart $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
shutdown)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Shutdowning $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS shutdown $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
try-restart)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Try restarting $DESC" "$NAME"
|
||||
$RUNIT $RUNIT_ARGS try-restart $NAME
|
||||
[ "$VERBOSE" != no ] && log_end_msg $?
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|force-restart|force-shutdown|force-stop|restart|shutdown|try-restart}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
|
Reference in New Issue
Block a user