capistrano-foreman 0.0.3 → 1.0.0

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.
data/README.md CHANGED
@@ -1,11 +1,30 @@
1
1
  # Capistrano Foreman
2
2
 
3
+ [![Code Climate](https://codeclimate.com/github/hyperoslo/capistrano-foreman.png)](https://codeclimate.com/github/hyperoslo/capistrano-foreman)
4
+
3
5
  Capistrano tasks for foreman and upstart.
4
6
 
5
7
  ## Installation
6
8
 
7
9
  $ gem install capistrano-foreman
8
10
 
11
+ Add this to your `Capfile`:
12
+
13
+ ```ruby
14
+ require 'capistrano/foreman'
15
+
16
+ # Default settings
17
+ set :foreman_sudo, 'sudo' # Set to `rvmsudo` if you're using RVM
18
+ set :foreman_upstart_path, '/etc/init/sites' # Set to `/etc/init/` if you don't have a sites folder
19
+ set :foreman_options, {
20
+ app: application,
21
+ log: "#{shared_path}/log",
22
+ user: user,
23
+ }
24
+ ```
25
+
26
+ See [exporting options](http://ddollar.github.io/foreman/#EXPORTING0) for an exhaustive list of foreman options.
27
+
9
28
  ## Usage
10
29
 
11
30
  Export Procfile to upstart:
@@ -15,3 +34,8 @@ Export Procfile to upstart:
15
34
  Restart the application services:
16
35
 
17
36
  $ cap foreman:restart
37
+
38
+ ## Credits
39
+
40
+ Hyper made this. We're a digital communications agency with a passion for good code,
41
+ and if you're using this library we probably want to hire you.
@@ -1,25 +1,44 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do |configuration|
2
2
 
3
+ _cset :foreman_sudo, "sudo"
4
+ _cset :foreman_upstart_path, "/etc/init/sites"
5
+ _cset :foreman_options, {}
6
+ _cset :foreman_use_binstubs, false
7
+
3
8
  namespace :foreman do
4
9
  desc "Export the Procfile to Ubuntu's upstart scripts"
5
10
  task :export, roles: :app do
6
- run "cd #{current_path} && sudo bundle exec foreman export upstart /etc/init -a sites/#{application} -u #{user} -l #{shared_path}/log"
11
+ cmd = foreman_use_binstubs ? 'bin/foreman' : 'bundle exec foreman'
12
+ run "if [[ -d #{foreman_upstart_path} ]]; then #{foreman_sudo} mkdir -p #{foreman_upstart_path}; fi"
13
+ run "cd #{release_path} && #{foreman_sudo} #{cmd} export upstart #{foreman_upstart_path} #{format(options)}"
7
14
  end
8
15
 
9
16
  desc "Start the application services"
10
17
  task :start, roles: :app do
11
- sudo "service sites/#{application} start"
18
+ sudo "service #{options[:app]} start"
12
19
  end
13
20
 
14
21
  desc "Stop the application services"
15
22
  task :stop, roles: :app do
16
- sudo "service sites/#{application} stop"
23
+ sudo "service #{options[:app]} stop"
17
24
  end
18
25
 
19
26
  desc "Restart the application services"
20
27
  task :restart, roles: :app do
21
- run "sudo service sites/#{application} start || sudo service sites/#{application} restart"
28
+ run "sudo service #{options[:app]} start || sudo service #{options[:app]} restart"
29
+ end
30
+
31
+ def options
32
+ {
33
+ app: application,
34
+ log: "#{shared_path}/log",
35
+ user: user
36
+ }.merge foreman_options
22
37
  end
23
- end
24
38
 
39
+ def format opts
40
+ opts.map { |opt, value| "--#{opt}='#{value}'" }.join " "
41
+ end
42
+ end
43
+
25
44
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Foreman
3
- VERSION = "0.0.3"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.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: 2012-06-14 00:00:00.000000000 Z
12
+ date: 2013-09-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Capistrano tasks for foreman and upstart.
15
15
  email:
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  version: '0'
48
48
  requirements: []
49
49
  rubyforge_project:
50
- rubygems_version: 1.8.11
50
+ rubygems_version: 1.8.23
51
51
  signing_key:
52
52
  specification_version: 3
53
53
  summary: Capistrano tasks for foreman and upstart.