osp-deploy 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,8 +8,9 @@ class OspDeploy::RailsDeployer
8
8
  DEPLOY_CONFIG_FILE = "config/osp-deploy.yml"
9
9
 
10
10
  REQUIRED_OPTIONS = { :always => [:jobs, :server_uris, :tag_prefix],
11
- :torquebox => [:appl_name, :torquebox_home, :remote_dest_file_dir],
11
+ :puma => [:remote_dest_file_dir],
12
12
  :file => [:remote_dest_file_dir],
13
+ :torquebox => [:appl_name, :torquebox_home, :remote_dest_file_dir],
13
14
  :precompile_assets => [:environment],
14
15
  }
15
16
 
@@ -125,6 +126,7 @@ EOT
125
126
  precompile_assets if @deployment_config['jobs'].include?(:precompile_assets)
126
127
  sync_files_to_remote_server(server_uri)
127
128
  torquebox_deploy(server_uri) if @deployment_config['jobs'].include?(:torquebox)
129
+ puma_deploy(server_uri) if @deployment_config['jobs'].include?(:puma)
128
130
  precompile_assets_housekeeping if @deployment_config['jobs'].include?(:precompile_assets)
129
131
  end
130
132
  end
@@ -145,6 +147,7 @@ EOT
145
147
  sync_files_to_remote_server(server_uri)
146
148
  bundler_actions_on_remote_server(server_uri)
147
149
  torquebox_deploy(server_uri) if @deployment_config['jobs'].include?(:torquebox)
150
+ puma_deploy(server_uri) if @deployment_config['jobs'].include?(:puma)
148
151
  precompile_assets_housekeeping if @deployment_config['jobs'].include?(:precompile_assets)
149
152
  end
150
153
  end
@@ -300,6 +303,39 @@ EOS
300
303
  end
301
304
 
302
305
 
306
+ def puma_deploy server_uri
307
+ file_dir = @deployment_config['remote_dest_file_dir']
308
+ puma_options = @deployment_config['puma_options'] || {}
309
+ puma_config_filepath = File.join 'config', 'puma.rb'
310
+ if File.exist? puma_config_filepath
311
+ puma_config = File.readlines puma_config_filepath
312
+ else
313
+ puma_config = []
314
+ end
315
+ # always set rails environment
316
+ puma_options[:environment] = @deployment_config['environment']
317
+ puma_options.each do |name, value|
318
+ ix = puma_config.index{|l| l =~ /^#{name}\s+/}
319
+ cfg_line = "#{name} '#{value}'"
320
+ if ix
321
+ puma_config[ix] = cfg_line
322
+ else
323
+ puma_config << cfg_line
324
+ end
325
+ end
326
+ conf_file = Tempfile.new(['osp-deploy-puma', '.rb'])
327
+ conf_content = puma_config.join("\n")
328
+ conf_file.write conf_content
329
+ conf_file.close
330
+ deployment_file = "#{file_dir}/config/puma.rb"
331
+ logger.info "Create puma config file: #{deployment_file}"
332
+ logger.debug "Content of puma.rb:\n#{'='*20}\n#{conf_content}\n#{'='*20}"
333
+ execute_cmd "scp #{conf_file.path} #{server_uri}:#{deployment_file}"
334
+ conf_file.delete
335
+ logger.info "Restart puma"
336
+ execute_cmd "ssh #{server_uri} \"cd #{file_dir} && bin/puma-app.sh restart\" "
337
+ end
338
+
303
339
 
304
340
 
305
341
  # read current branch
@@ -1,3 +1,3 @@
1
1
  module OspDeploy
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osp-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-28 00:00:00.000000000 Z
12
+ date: 2014-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake