atech_cloud 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,11 @@ Capistrano::Configuration.instance(:must_exist).load do
9
9
  fetch(:deploy_to, nil) || "/opt/apps/#{fetch(:application)}"
10
10
  end
11
11
 
12
+ ## Return an array of all environments which should be deployed
13
+ def environments
14
+ fetch(:environments, nil) || [fetch(:environment, 'production')]
15
+ end
16
+
12
17
  ## Deployment namespace
13
18
  namespace :deploy do
14
19
  desc 'Deploy the latest revision of the application'
@@ -45,20 +50,6 @@ Capistrano::Configuration.instance(:must_exist).load do
45
50
 
46
51
  desc 'Setup the repository on the remote server for the first time'
47
52
  task :setup, :roles => :app do
48
-
49
- puts
50
- puts "Are you sure you wish to setup this application?"
51
- puts "Any applications existing at \e[31m#{deploy_to}\e[0m will be removed immediately and will"
52
- puts "become unaccessible."
53
- puts
54
- puts "If you do not wish this to happen, you have 5 seconds to cancel this request by"
55
- puts "pressing CTRL+C..."
56
- puts
57
- sleep 5
58
- puts
59
- puts "OK then... here we go..."
60
- sleep 1
61
-
62
53
  run "rm -rf #{deploy_to}"
63
54
  run "git clone -n #{fetch(:repository)} #{deploy_to} --branch #{fetch(:branch)}"
64
55
  run "cd #{deploy_to} && git branch rollback && git checkout -b deploy && git branch -d #{fetch(:branch)}"
@@ -125,16 +116,22 @@ Capistrano::Configuration.instance(:must_exist).load do
125
116
  namespace :unicorn do
126
117
  task :start, :roles => :app do
127
118
  upload_config
128
- run "sudo -u app sh -c \"umask 002 && cd #{deploy_to} && bundle exec unicorn_rails -E #{fetch(:environment)} -c #{deploy_to}/config/unicorn.rb -D\""
119
+ for environment in environments
120
+ run "sudo -u app sh -c \"umask 002 && cd #{deploy_to} && bundle exec unicorn_rails -E #{environment} -c #{deploy_to}/config/unicorn.rb -D\""
121
+ end
129
122
  end
130
123
 
131
124
  task :stop, :roles => :app do
132
- run "sudo -u app sh -c \"kill `cat #{deploy_to}/tmp/pids/unicorn.pid`\""
125
+ for environment in environments
126
+ run "sudo -u app sh -c \"kill `cat #{deploy_to}/tmp/pids/unicorn.#{environment}.pid`\""
127
+ end
133
128
  end
134
129
 
135
130
  task :restart, :roles => :app do
136
131
  upload_config
137
- run "sudo -u app sh -c \"kill -USR2 `cat #{deploy_to}/tmp/pids/unicorn.pid`\""
132
+ for environment in environments
133
+ run "sudo -u app sh -c \"kill -USR2 `cat #{deploy_to}/tmp/pids/unicorn.#{environment}.pid`\""
134
+ end
138
135
  end
139
136
 
140
137
  task :upload_config, :roles => :app do
@@ -1,3 +1,5 @@
1
+ rails_env = ENV['RAILS_ENV'] || 'production'
2
+
1
3
  ## Directory to use for stuff
2
4
  rails_root = File.expand_path('../../', __FILE__)
3
5
  FileUtils.mkdir_p(File.join(rails_root, 'tmp', 'sockets'))
@@ -15,11 +17,11 @@ preload_app true
15
17
  timeout $TIMEOUT
16
18
 
17
19
  ## Store the pid file safely away in the pids folder
18
- logger Logger.new(File.join(rails_root, 'log', 'unicorn.log'))
19
- pid File.join(rails_root, 'tmp', 'pids', 'unicorn.pid')
20
+ logger Logger.new(File.join(rails_root, 'log', "unicorn.#{rails_env}.log"))
21
+ pid File.join(rails_root, 'tmp', 'pids', "unicorn.#{rails_env}.pid")
20
22
 
21
23
  ## Listen on a unix data socket
22
- listen File.join(rails_root, 'tmp', 'sockets', 'unicorn.sock')
24
+ listen File.join(rails_root, 'tmp', 'sockets', "unicorn.#{rails_env}.sock")
23
25
 
24
26
  before_fork do |server, worker|
25
27
  # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
@@ -32,7 +34,7 @@ before_fork do |server, worker|
32
34
  #
33
35
  # Using this method we get 0 downtime deploys.
34
36
 
35
- old_pid = File.join(rails_root, 'tmp', 'pids', 'unicorn.pid.oldbin')
37
+ old_pid = File.join(rails_root, 'tmp', 'pids', "unicorn.#{rails_env}.pid.oldbin")
36
38
  if File.exists?(old_pid) && server.pid != old_pid
37
39
  begin
38
40
  Process.kill("QUIT", File.read(old_pid).to_i)
@@ -49,4 +51,3 @@ after_fork do |server, worker|
49
51
  ActiveRecord::Base.establish_connection
50
52
  srand
51
53
  end
52
-
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atech_cloud
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
10
- version: 1.0.5
9
+ - 6
10
+ version: 1.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adam Cooke
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-06 00:00:00 +01:00
18
+ date: 2011-04-08 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21