default[:passenger][:ruby_version] = node[:lsb][:release].to_f >= 18.04 ? "2.5" : "2.3"
default[:passenger][:max_pool_size] = 6
default[:passenger][:pool_idle_time] = 300
+default[:passenger][:instance_registry_dir] = "/run/passenger"
default[:apt][:sources] = node[:apt][:sources] | ["passenger"]
notifies :reload, "service[apache2]"
end
+systemd_tmpfile node[:passenger][:instance_registry_dir] do
+ type "d"
+ owner "root"
+ group "root"
+ mode "0755"
+end
+
apache_module "passenger" do
conf "passenger.conf.erb"
end
+munin_plugin_conf "passenger" do
+ template "munin.erb"
+end
+
munin_plugin "passenger_memory"
munin_plugin "passenger_processes"
munin_plugin "passenger_queues"
--- /dev/null
+#
+# Cookbook Name:: passenger
+# Resource:: application
+#
+# Copyright 2018, OpenStreetMap Foundation
+#
+# 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
+#
+# https://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_action :nothing
+
+property :application, String, :name_attribute => true
+
+action :restart do
+ execute new_resource.application do
+ action :run
+ command "passenger-config restart-app --ignore-app-not-running --ignore-passenger-not-running #{new_resource.application}"
+ environment "PASSENGER_INSTANCE_REGISTRY_DIR" => node[:passenger][:instance_registry_dir]
+ user "root"
+ group "root"
+ end
+end
--- /dev/null
+# DO NOT EDIT - This file is being maintained by Chef
+
+[passenger_*]
+user root
+env.PASSENGER_INSTANCE_REGISTRY_DIR <%= node[:passenger][:instance_registry_dir] %>
PassengerMaxPoolSize <%= node[:passenger][:max_pool_size] %>
PassengerPoolIdleTime <%= node[:passenger][:pool_idle_time] %>
PassengerFriendlyErrorPages off
+ PassengerInstanceRegistryDir /run/passenger
</IfModule>
mv $ROOT/sources/taginfo-*.db $ROOT/sources/*/taginfo-*.db $ROOT/data
mv $ROOT/sources/download/* $ROOT/download
-sudo /usr/bin/passenger-config restart-app $ROOT/taginfo/web > /dev/null
+sudo PASSENGER_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> /usr/bin/passenger-config restart-app $ROOT/taginfo/web > /dev/null
find $ROOT/sources/log -mtime +28 -delete
notifies :run, "execute[#{rails_directory}/Gemfile]"
notifies :run, "execute[#{rails_directory}/public/assets]"
notifies :delete, "file[#{rails_directory}/public/export/embed.html]"
- notifies :run, "execute[#{rails_directory}]"
+ notifies :restart, "passenger_application[#{rails_directory}]"
end
declare_resource :directory, "#{rails_directory}/tmp" do
:name => new_resource.database_name,
:username => new_resource.database_username,
:password => new_resource.database_password
- notifies :run, "execute[#{rails_directory}]"
+ notifies :restart, "passenger_application[#{rails_directory}]"
end
application_yml = edit_file "#{rails_directory}/config/example.application.yml" do |line|
group "root"
environment "NOKOGIRI_USE_SYSTEM_LIBRARIES" => "yes"
subscribes :run, "gem_package[bundler#{new_resource.ruby}]"
- notifies :run, "execute[#{rails_directory}]"
+ notifies :restart, "passenger_application[#{rails_directory}]"
end
execute "#{rails_directory}/db/migrate" do
user new_resource.user
group new_resource.group
subscribes :run, "git[#{rails_directory}]"
- notifies :run, "execute[#{rails_directory}]"
+ notifies :restart, "passenger_application[#{rails_directory}]"
only_if { new_resource.run_migrations }
end
cwd rails_directory
user new_resource.user
group new_resource.group
- notifies :run, "execute[#{rails_directory}]"
+ notifies :restart, "passenger_application[#{rails_directory}]"
end
file "#{rails_directory}/public/export/embed.html" do
action :nothing
end
- execute rails_directory do
- action :nothing
- command "passenger-config restart-app --ignore-app-not-running --ignore-passenger-not-running #{rails_directory}"
- user "root"
- group "root"
- only_if { ::File.exist?("/usr/bin/passenger-config") }
- end
+ passenger_application rails_directory
template "/etc/cron.daily/rails-#{new_resource.site.tr('.', '-')}" do
cookbook "web"
end
action :restart do
- execute rails_directory do
- action :run
- command "passenger-config restart-app --ignore-app-not-running --ignore-passenger-not-running #{rails_directory}"
- user "root"
- group "root"
+ passenger_application rails_directory do
+ action :restart
end
end
sharedscripts
postrotate
<% if File.directory?("#{node[:web][:base_directory]}/rails") -%>
- /usr/bin/passenger-config restart-app --ignore-app-not-running <%= node[:web][:base_directory] %>/rails > /dev/null
+ PASSENGER_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> /usr/bin/passenger-config restart-app --ignore-app-not-running <%= node[:web][:base_directory] %>/rails > /dev/null
<% if node[:recipes].include?("logstash::forwarder") -%>
/etc/init.d/logstash-forwarder restart > /dev/null
<% end -%>
pgrep -u rails -f Rack | sort > /tmp/rails.actual.$$
# Get a list of rack processes we expect to be running
-passenger-status | awk '/PID:/ { print $3 }' | sort > /tmp/rails.expected.$$
+PASSENGER_INSTANCE_REGISTRY_DIR=<%= node[:passenger][:instance_registry_dir] %> passenger-status | awk '/PID:/ { print $3 }' | sort > /tmp/rails.expected.$$
# Get a list of unexpected rack processes
pids=$(comm -23 /tmp/rails.actual.$$ /tmp/rails.expected.$$)