Dev set up
This commit is contained in:
143
ops/cookbooks/vendor/memcached/resources/instance_runit.rb
vendored
Normal file
143
ops/cookbooks/vendor/memcached/resources/instance_runit.rb
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
#
|
||||
# Cookbook:: memcached
|
||||
# resource:: instance_runit
|
||||
#
|
||||
# Author:: Tim Smith <tsmith@chef.io>
|
||||
# Copyright:: 2009-2016, 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.
|
||||
#
|
||||
|
||||
property :instance_name, String, name_property: true
|
||||
property :memory, [Integer, String], default: 64
|
||||
property :port, [Integer, String], default: 11_211
|
||||
property :udp_port, [Integer, String], default: 11_211
|
||||
property :listen, String, default: '0.0.0.0'
|
||||
property :maxconn, [Integer, String], default: 1024
|
||||
property :user, String, default: lazy { service_user }
|
||||
property :binary_path, String
|
||||
property :threads, [Integer, String]
|
||||
property :max_object_size, String, default: '1m'
|
||||
property :experimental_options, Array, default: []
|
||||
property :extra_cli_options, Array, default: []
|
||||
property :ulimit, [Integer, String], default: 1024
|
||||
property :template_cookbook, String, default: 'memcached'
|
||||
property :disable_default_instance, [true, false], default: true
|
||||
property :remove_default_config, [true, false], default: true
|
||||
property :log_level, String, default: 'info'
|
||||
|
||||
action :start do
|
||||
Chef::Log.warn('The memcached_instance_runit resource has been deprecated as of 9/2017. This resource will be removed in the next major release of the memcached cookbook. We highly recommend using your distributions native init systeam instead.')
|
||||
|
||||
create_init
|
||||
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
supports restart: true, status: true
|
||||
action :start
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
supports status: true
|
||||
action :stop
|
||||
only_if { ::File.exist?("/etc/sv/#{memcached_instance_name}/run") }
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
supports restart: true, status: true
|
||||
action :restart
|
||||
end
|
||||
end
|
||||
|
||||
action :enable do
|
||||
create_init
|
||||
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
supports status: true
|
||||
action :enable
|
||||
only_if { ::File.exist?("/etc/sv/#{memcached_instance_name}/run") }
|
||||
end
|
||||
end
|
||||
|
||||
action :disable do
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
supports status: true
|
||||
action :disable
|
||||
only_if { ::File.exist?("/etc/sv/#{memcached_instance_name}/run") }
|
||||
end
|
||||
end
|
||||
|
||||
### Legacy actions included for compatibility
|
||||
|
||||
action :remove do
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
action [:stop, :disable]
|
||||
only_if { ::File.exist?("/etc/sv/#{memcached_instance_name}/run") }
|
||||
end
|
||||
end
|
||||
|
||||
action :create do
|
||||
create_init
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
action [:start, :enable]
|
||||
end
|
||||
end
|
||||
|
||||
action_class do
|
||||
def create_init
|
||||
include_recipe 'runit'
|
||||
include_recipe 'memcached::_package' unless new_resource.binary_path
|
||||
|
||||
# Disable the default memcached service to avoid port conflicts + wasted memory
|
||||
disable_default_memcached_instance
|
||||
|
||||
# cleanup default configs to avoid confusion
|
||||
remove_default_memcached_configs
|
||||
|
||||
runit_service memcached_instance_name do
|
||||
run_template_name 'memcached'
|
||||
default_logger true
|
||||
cookbook new_resource.template_cookbook
|
||||
options(
|
||||
ulimit: new_resource.ulimit,
|
||||
user: new_resource.user,
|
||||
binary_path: binary_path,
|
||||
cli_options: cli_options
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
128
ops/cookbooks/vendor/memcached/resources/instance_systemd.rb
vendored
Normal file
128
ops/cookbooks/vendor/memcached/resources/instance_systemd.rb
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
#
|
||||
# Cookbook:: memcached
|
||||
# resource:: instance_systemd
|
||||
#
|
||||
# Author:: Tim Smith <tsmith@chef.io>
|
||||
# Copyright:: 2016, 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.
|
||||
#
|
||||
|
||||
provides :memcached_instance_systemd
|
||||
|
||||
provides :memcached_instance, os: 'linux' do |_node|
|
||||
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:systemd)
|
||||
end
|
||||
|
||||
property :instance_name, String, name_property: true
|
||||
property :memory, [Integer, String], default: 64
|
||||
property :port, [Integer, String], default: 11_211
|
||||
property :udp_port, [Integer, String], default: 11_211
|
||||
property :listen, String, default: '0.0.0.0'
|
||||
property :maxconn, [Integer, String], default: 1024
|
||||
property :user, String, default: lazy { service_user }
|
||||
property :binary_path, String
|
||||
property :threads, [Integer, String]
|
||||
property :max_object_size, String, default: '1m'
|
||||
property :experimental_options, Array, default: []
|
||||
property :extra_cli_options, Array, default: []
|
||||
property :ulimit, [Integer, String], default: 1024
|
||||
property :template_cookbook, String, default: 'memcached'
|
||||
property :disable_default_instance, [true, false], default: true
|
||||
property :remove_default_config, [true, false], default: true
|
||||
property :no_restart, [true, false], default: false
|
||||
property :log_level, String, default: 'info'
|
||||
|
||||
action :start do
|
||||
create_init
|
||||
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports restart: true, status: true
|
||||
action :start
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports status: true
|
||||
action :stop
|
||||
only_if { ::File.exist?("/etc/systemd/system/#{memcached_instance_name}.service") }
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports restart: true, status: true
|
||||
action :restart
|
||||
end
|
||||
end
|
||||
|
||||
action :disable do
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports status: true
|
||||
action :disable
|
||||
only_if { ::File.exist?("/etc/systemd/system/#{memcached_instance_name}.service") }
|
||||
end
|
||||
end
|
||||
|
||||
action :enable do
|
||||
create_init
|
||||
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports status: true
|
||||
action :enable
|
||||
end
|
||||
end
|
||||
|
||||
action_class do
|
||||
def create_init
|
||||
include_recipe 'memcached::_package' unless new_resource.binary_path
|
||||
|
||||
# remove any runit instances with the same name if they exist
|
||||
disable_legacy_runit_instance
|
||||
|
||||
# Disable the default memcached service to avoid port conflicts + wasted memory
|
||||
disable_default_memcached_instance
|
||||
|
||||
# cleanup default configs to avoid confusion
|
||||
remove_default_memcached_configs
|
||||
|
||||
template "/etc/systemd/system/#{memcached_instance_name}.service" do
|
||||
source 'init_systemd.erb'
|
||||
variables(
|
||||
instance: memcached_instance_name,
|
||||
ulimit: new_resource.ulimit,
|
||||
user: new_resource.user,
|
||||
binary_path: binary_path,
|
||||
cli_options: cli_options
|
||||
)
|
||||
cookbook new_resource.template_cookbook
|
||||
notifies :run, 'execute[reload_unit_file]', :immediately
|
||||
notifies :restart, "service[#{memcached_instance_name}]", :immediately unless new_resource.no_restart
|
||||
owner 'root'
|
||||
group 'root'
|
||||
mode '0644'
|
||||
end
|
||||
|
||||
# systemd is cool like this
|
||||
execute 'reload_unit_file' do
|
||||
command 'systemctl daemon-reload'
|
||||
action :nothing
|
||||
end
|
||||
end
|
||||
end
|
131
ops/cookbooks/vendor/memcached/resources/instance_sysv_init.rb
vendored
Normal file
131
ops/cookbooks/vendor/memcached/resources/instance_sysv_init.rb
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
#
|
||||
# Cookbook:: memcached
|
||||
# resource:: instance_sysv_init
|
||||
#
|
||||
# Author:: Tim Smith <tsmith@chef.io>
|
||||
# Copyright:: 2016, 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.
|
||||
#
|
||||
|
||||
provides :memcached_instance_sysv_init
|
||||
|
||||
provides :memcached_instance, os: 'linux'
|
||||
|
||||
property :instance_name, String, name_property: true
|
||||
property :memory, [Integer, String], default: 64
|
||||
property :port, [Integer, String], default: 11_211
|
||||
property :udp_port, [Integer, String], default: 11_211
|
||||
property :listen, String, default: '0.0.0.0'
|
||||
property :maxconn, [Integer, String], default: 1024
|
||||
property :user, String, default: lazy { service_user }
|
||||
property :binary_path, String
|
||||
property :threads, [Integer, String]
|
||||
property :max_object_size, String, default: '1m'
|
||||
property :experimental_options, Array, default: []
|
||||
property :extra_cli_options, Array, default: []
|
||||
property :ulimit, [Integer, String], default: 1024
|
||||
property :template_cookbook, String, default: 'memcached'
|
||||
property :disable_default_instance, [true, false], default: true
|
||||
property :remove_default_config, [true, false], default: true
|
||||
property :no_restart, [true, false], default: false
|
||||
property :log_level, String, default: 'info'
|
||||
|
||||
action :start do
|
||||
create_init
|
||||
|
||||
service memcached_instance_name do
|
||||
provider platform_sysv_init_class
|
||||
supports restart: true, status: true
|
||||
action :start
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
service memcached_instance_name do
|
||||
provider platform_sysv_init_class
|
||||
supports status: true
|
||||
action :stop
|
||||
only_if { ::File.exist?("/etc/init.d/#{memcached_instance_name}") }
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
service memcached_instance_name do
|
||||
provider platform_sysv_init_class
|
||||
supports restart: true, status: true
|
||||
action :restart
|
||||
end
|
||||
end
|
||||
|
||||
action :enable do
|
||||
create_init
|
||||
|
||||
service memcached_instance_name do
|
||||
provider platform_sysv_init_class
|
||||
supports status: true
|
||||
action :enable
|
||||
only_if { ::File.exist?("/etc/init.d/#{memcached_instance_name}") }
|
||||
end
|
||||
end
|
||||
|
||||
action :disable do
|
||||
service memcached_instance_name do
|
||||
provider platform_sysv_init_class
|
||||
supports status: true
|
||||
action :disable
|
||||
only_if { ::File.exist?("/etc/init.d/#{memcached_instance_name}") }
|
||||
end
|
||||
end
|
||||
|
||||
action_class do
|
||||
def create_init
|
||||
include_recipe 'memcached::_package' unless new_resource.binary_path
|
||||
|
||||
# remove any runit instances with the same name if they exist
|
||||
disable_legacy_runit_instance
|
||||
|
||||
# Disable the default memcached service to avoid port conflicts + wasted memory
|
||||
disable_default_memcached_instance
|
||||
|
||||
# cleanup default configs to avoid confusion
|
||||
remove_default_memcached_configs
|
||||
|
||||
# the init script will not run without redhat-lsb packages
|
||||
package 'redhat-lsb-core' if platform_family?('fedora', 'rhel', 'amazon')
|
||||
|
||||
# create the log file so we can write to it
|
||||
create_log_file
|
||||
|
||||
# remove the debian defaults dir
|
||||
file '/etc/default/memcached' do
|
||||
action :delete
|
||||
end
|
||||
|
||||
template "/etc/init.d/#{memcached_instance_name}" do
|
||||
mode '0755'
|
||||
source platform_family?('debian') ? 'init_sysv_debian.erb' : 'init_sysv.erb'
|
||||
cookbook new_resource.template_cookbook
|
||||
variables(
|
||||
lock_dir: lock_dir,
|
||||
instance: memcached_instance_name,
|
||||
ulimit: new_resource.ulimit,
|
||||
user: new_resource.user,
|
||||
binary_path: binary_path,
|
||||
cli_options: cli_options,
|
||||
log_file: log_file_name
|
||||
)
|
||||
notifies :restart, "service[#{memcached_instance_name}]", :immediately unless new_resource.no_restart
|
||||
end
|
||||
end
|
||||
end
|
130
ops/cookbooks/vendor/memcached/resources/instance_upstart.rb
vendored
Normal file
130
ops/cookbooks/vendor/memcached/resources/instance_upstart.rb
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
#
|
||||
# Cookbook:: memcached
|
||||
# resource:: instance_upstart
|
||||
#
|
||||
# Author:: Tim Smith <tsmith@chef.io>
|
||||
# Copyright:: 2016, 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.
|
||||
#
|
||||
|
||||
provides :memcached_instance_upstart
|
||||
|
||||
provides :memcached_instance, platform_family: 'debian' do |_node|
|
||||
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart) &&
|
||||
!Chef::Platform::ServiceHelpers.service_resource_providers.include?(:systemd)
|
||||
end
|
||||
|
||||
property :instance_name, String, name_property: true
|
||||
property :memory, [Integer, String], default: 64
|
||||
property :port, [Integer, String], default: 11_211
|
||||
property :udp_port, [Integer, String], default: 11_211
|
||||
property :listen, String, default: '0.0.0.0'
|
||||
property :maxconn, [Integer, String], default: 1024
|
||||
property :user, String, default: lazy { service_user }
|
||||
property :binary_path, String
|
||||
property :threads, [Integer, String]
|
||||
property :max_object_size, String, default: '1m'
|
||||
property :experimental_options, Array, default: []
|
||||
property :extra_cli_options, Array, default: []
|
||||
property :ulimit, [Integer, String], default: 1024
|
||||
property :template_cookbook, String, default: 'memcached'
|
||||
property :disable_default_instance, [true, false], default: true
|
||||
property :remove_default_config, [true, false], default: true
|
||||
property :no_restart, [true, false], default: false
|
||||
property :log_level, String, default: 'info'
|
||||
|
||||
action :start do
|
||||
create_init
|
||||
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
supports restart: true, status: true
|
||||
action :start
|
||||
end
|
||||
end
|
||||
|
||||
action :stop do
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
supports status: true
|
||||
action :stop
|
||||
only_if { ::File.exist?("/etc/init/#{memcached_instance_name}.conf") }
|
||||
end
|
||||
end
|
||||
|
||||
action :restart do
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
supports restart: true, status: true
|
||||
action :restart
|
||||
end
|
||||
end
|
||||
|
||||
action :enable do
|
||||
create_init
|
||||
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
supports status: true
|
||||
action :enable
|
||||
only_if { ::File.exist?("/etc/init/#{memcached_instance_name}.conf") }
|
||||
end
|
||||
end
|
||||
|
||||
action :disable do
|
||||
service memcached_instance_name do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
supports status: true
|
||||
action :disable
|
||||
only_if { ::File.exist?("/etc/init/#{memcached_instance_name}.conf") }
|
||||
end
|
||||
end
|
||||
|
||||
action_class do
|
||||
def create_init
|
||||
include_recipe 'memcached::_package' unless new_resource.binary_path
|
||||
|
||||
# remove any runit instances with the same name if they exist
|
||||
disable_legacy_runit_instance
|
||||
|
||||
# Disable the default memcached service to avoid port conflicts + wasted memory
|
||||
disable_default_memcached_instance
|
||||
|
||||
# remove the default init script if our service is also named
|
||||
# memcached so we don't have both an upstart script and an sys-v script
|
||||
file '/etc/init.d/memcached' do
|
||||
action :delete
|
||||
only_if { new_resource.instance_name == 'memcached' }
|
||||
end
|
||||
|
||||
# cleanup default configs to avoid confusion
|
||||
remove_default_memcached_configs
|
||||
|
||||
# create the log file so we can write to it
|
||||
create_log_file
|
||||
|
||||
template "/etc/init/#{memcached_instance_name}.conf" do
|
||||
source 'init_upstart.erb'
|
||||
variables(
|
||||
instance: memcached_instance_name,
|
||||
ulimit: new_resource.ulimit,
|
||||
binary_path: binary_path,
|
||||
cli_options: cli_options,
|
||||
log_file: log_file_name
|
||||
)
|
||||
cookbook new_resource.template_cookbook
|
||||
notifies :restart, "service[#{memcached_instance_name}]", :immediately unless new_resource.no_restart
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user