caploy 0.2.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,90 +0,0 @@
1
-
2
- #
3
- # sudoers:
4
- # %deploy ALL=(ALL) NOPASSWD: /usr/local/bin/bluepill, /sbin/start my_app_bluepill , /sbin/stop my_app_bluepill
5
- # sudo chown root:root deploy_conf
6
- # sudo chmod 0440 deploy_conf
7
- # => /etc/sudoers.d
8
- #
9
- Capistrano::Configuration.instance.load do
10
-
11
- namespace :deploy do
12
-
13
- task :start, :roles => :app, :except => { :no_release => true } do
14
- sudo 'start bluepill_conf'
15
- end
16
-
17
- task :stop, :roles => :app, :except => { :no_release => true } do
18
- sudo "bluepill stop"
19
- sudo "stop bluepill_conf"
20
- end
21
-
22
- task :restart, :roles => :app, :except => { :no_release => true } do
23
- sudo "bluepill restart unicorn"
24
- end
25
-
26
- #desc "Restart Resque Workers"
27
- #task :restart_workers do
28
- # sudo "bluepill stop resque"
29
- # sudo "bluepill start resque"
30
- #end
31
- #
32
- #desc "Start Resque Workers"
33
- #task :start_workers do
34
- # sudo "bluepill start resque"
35
- #end
36
- #
37
- #desc "Stop Resque Workers"
38
- #task :stop_workers do
39
- # sudo "bluepill stop resque"
40
- #end
41
-
42
- end
43
-
44
- namespace :bluepill do
45
- desc "Prints bluepills monitored processes statuses"
46
- task :status, :roles => [:app] do
47
- sudo "bluepill status"
48
- end
49
-
50
- desc "Setup blupill config"
51
- task :setup, :roles => [:app] do
52
- setup_init
53
- setup_config
54
- end
55
-
56
- task :setup_init do
57
- template_path = File.expand_path('../../templates/bluepill/init.erb', __FILE__)
58
- vars = {
59
- 'application' => application,
60
- 'config_path' => fetch(:bluepill_config_path, "#{shared_path}/config/bluepill_config.pill")
61
- }
62
-
63
- config_path = "#{shared_path}/config/bluepill_init.conf"
64
-
65
- put(render_erb_template(template_path, vars), config_path)
66
- sudo "rm -f /etc/init/bluepill_#{application}_#{stage}.conf"
67
- sudo "ln -s #{config_path} /etc/init/bluepill_#{application}_#{stage}.conf"
68
- end
69
-
70
- task :setup_config do
71
- template_path = File.expand_path('../../templates/bluepill/default_config.rb.erb', __FILE__)
72
- log_file = "#{latest_release}/log/bluepill.log"
73
- unicorn_config_path = "#{shared_path}/config/unicorn/#{stage}.rb"
74
- vars = {
75
- 'application' => application,
76
- 'stage' => stage,
77
- 'log_file' => log_file,
78
- 'unicorn_config_path' => unicorn_config_path
79
- }
80
-
81
- config_path = fetch(:bluepill_config_path, "#{shared_path}/config/bluepill_config.pill")
82
- put(render_erb_template(template_path, vars), config_path)
83
-
84
- end
85
- end
86
-
87
- #after "deploy:restart", "deploy:restart_workers"
88
- after "deploy:setup", "bluepill:setup"
89
-
90
- end
@@ -1,8 +0,0 @@
1
- Capistrano::Configuration.instance.load do
2
-
3
- #set :whenever_environment, defer { stage }
4
- #set :whenever_identifier, defer { "#{application}_#{stage}" }
5
- #set :whenever_command, "bundle exec whenever"
6
- #require "whenever/capistrano"
7
-
8
- end
@@ -1,9 +0,0 @@
1
- description "<%= application %>"
2
-
3
- start on runlevel [2]
4
- stop on runlevel [016]
5
-
6
- expect daemon
7
- exec bluepill load <%= config_path %>
8
-
9
- respawn
@@ -1,43 +0,0 @@
1
- ENV["RAILS_ENV"] = "<%= stage %>"
2
-
3
- Bluepill.application("<%= application %>-<%= stage %>", :log_file => '<%= log_file %>') do |app|
4
-
5
- app.process("unicorn") do |process|
6
- process.pid_file = '<%= unicorn_config_path %>'
7
- process.working_dir = '/var/my_app/current'
8
-
9
- process.start_command = "/usr/local/bin/bundle exec unicorn -c /var/my_app/current/config/unicorn.rb -E staging -D"
10
- process.stop_command = "kill -QUIT {{PID}}"
11
- process.restart_command = "kill -USR2 {{PID}}"
12
-
13
- process.uid = process.gid = 'deploy'
14
-
15
- process.start_grace_time = 30.seconds
16
- process.stop_grace_time = 30.seconds
17
- process.restart_grace_time = 30.seconds
18
-
19
-
20
- process.monitor_children do |child_process|
21
- child_process.stop_command = "kill -QUIT {{PID}}"
22
-
23
- child_process.checks :mem_usage, :every => 30.seconds, :below => 200.megabytes, :times => [3, 4], :fires => :stop
24
- child_process.checks :cpu_usage, :every => 30.seconds, :below => 40, :times => [3, 4], :fires => :stop
25
- end
26
- end
27
-
28
- 2.times do |i|
29
- app.process("resque-#{i}") do |process|
30
- process.working_dir = '/var/my_app/current'
31
- process.group = "resque"
32
- process.start_command = "/usr/local/bin/bundle exec rake resque:work"
33
- process.pid_file = "/var/my_app/shared/pids/my_app-resque-#{i}.pid"
34
- process.stop_command = "kill -QUIT {{PID}}"
35
- process.daemonize = true
36
-
37
- process.start_grace_time = 30.seconds
38
- process.stop_grace_time = 30.seconds
39
- process.uid = process.gid = 'deploy'
40
-
41
- end
42
- end
43
- end