Skip to content

Instantly share code, notes, and snippets.

@izakp
Created Mar 26, 2014
Embed
What would you like to do?
diff --git a/cookbooks/apn_sender/recipes/default.rb b/cookbooks/apn_sender/recipes/default.rb
new file mode 100644
index 0000000..903aecc
--- /dev/null
+++ b/cookbooks/apn_sender/recipes/default.rb
@@ -0,0 +1,33 @@
+#
+# Cookbook Name:: resque
+# Recipe:: default
+#
+
+if node[:instance_role] == 'solo' || (node[:instance_role] == 'util' && node[:name] == 'resque')
+
+ node[:applications].each do |app, data|
+
+ if app == 'tape_express_api'
+
+ template "/etc/monit.d/apn_sender_#{app}.monitrc" do
+ owner 'root'
+ group 'root'
+ mode 0644
+ source "apn_sender.monitrc.erb"
+ variables(
+ :app_name => app,
+ :environment => node[:environment][:framework_env],
+ :pem_cert => node[:environment][:framework_env] == 'production' ? 'apn_production.pem' : 'apn_development.pem'
+ )
+ end
+
+ execute "ensure-apn_sender-is-setup-with-monit" do
+ epic_fail true
+ command %Q{
+ monit reload
+ }
+ end
+
+ end
+ end
+end
diff --git a/cookbooks/apn_sender/templates/default/apn_sender.monitrc.erb b/cookbooks/apn_sender/templates/default/apn_sender.monitrc.erb
new file mode 100644
index 0000000..647e417
--- /dev/null
+++ b/cookbooks/apn_sender/templates/default/apn_sender.monitrc.erb
@@ -0,0 +1,6 @@
+check process apn_sender
+ with pidfile /data/<%= @app_name %>/shared/pids/apn_sender.pid
+ group apn_sender
+ start program = "RAILS_ENV=<%= @environment %> APP_NAME=<%= @app_name %> /data/<%= @app_name %>/current/script/apn_sender --environment=<%= @environment %> --full-cert-path=/data/<%= @app_name %>/current/config/certs/<%= @app_name %>/<%= @pem_cert %> --verbose start"
+ stop program = "RAILS_ENV=<%= @environment %> APP_NAME=<%= @app_name %> /data/<%= @app_name %>/current/script/apn_sender --environment=<%= @environment %> --full-cert-path=/data/<%= @app_name %>/current/config/certs/<%= @app_name %>/<%= @pem_cert %> --verbose stop"
+
diff --git a/cookbooks/main/recipes/default.rb b/cookbooks/main/recipes/default.rb
index c613715..2961d7e 100644
--- a/cookbooks/main/recipes/default.rb
+++ b/cookbooks/main/recipes/default.rb
@@ -156,3 +156,5 @@ include_recipe "redis"
#end
include_recipe "jobs"
+
+include_recipe "apn_sender"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment