capistrano-foreman-systemd 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 20f43f605bd054bd0b93f27ed3a489dfa3196472
4
+ data.tar.gz: 8372b1200313fadf256ac4c47b9d708a65e8a437
5
+ SHA512:
6
+ metadata.gz: a5d9425c6c5376250d56dda5755a16f3575a69d5c3f8388782df7e68e84aa2ec0b98d9ac7cad9afd2a3c02e83e7b3756a1b5b3b83b0d6c943b73b71aef94c9aa
7
+ data.tar.gz: b9d42e2b9849aca49bc09d01cb3dbc4538c004fd7a2ea1051ecbde4f01061470fb2ef415cdcfe9bfac34c264c6881966eaea6f4d6ebc6a303541ce3fea7bbfa7
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Documentation cache and generated files:
13
+ /.yardoc/
14
+ /_yardoc/
15
+ /doc/
16
+ /rdoc/
17
+
18
+ ## Environment normalisation:
19
+ /.bundle/
20
+ /lib/bundler/man/
21
+
22
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-foreman.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Licensed under the **MIT** license
2
+
3
+ > Copyright (c) 2014 Hyper Interaktiv AS
4
+ >
5
+ > Permission is hereby granted, free of charge, to any person obtaining
6
+ > a copy of this software and associated documentation files (the
7
+ > "Software"), to deal in the Software without restriction, including
8
+ > without limitation the rights to use, copy, modify, merge, publish,
9
+ > distribute, sublicense, and/or sell copies of the Software, and to
10
+ > permit persons to whom the Software is furnished to do so, subject to
11
+ > the following conditions:
12
+ >
13
+ > The above copyright notice and this permission notice shall be
14
+ > included in all copies or substantial portions of the Software.
15
+ >
16
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ > IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ > CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ > TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # Capistrano::foreman
2
+
3
+ Foreman support for Capistrano 3
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem 'capistrano', '~> 3.1'
9
+ gem 'capistrano-foreman', github: 'koenpunt/capistrano-foreman'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install capistrano-foreman
19
+
20
+ ## Usage
21
+
22
+ Require in `Capfile`:
23
+
24
+ ```ruby
25
+ require 'capistrano/foreman'
26
+ ```
27
+
28
+ Export Procfile to process management format (defaults to upstart) and restart the application services:
29
+
30
+ $ cap foreman:setup
31
+ $ cap foreman:start
32
+
33
+ Configurable options, shown here with defaults:
34
+
35
+ ```ruby
36
+ set :foreman_roles, :all
37
+ set :foreman_export_format, 'upstart'
38
+ set :foreman_export_path, '/etc/init'
39
+ set :foreman_flags, "--root=#{current_path}" # optional, default is empty string
40
+ set :foreman_target_path, release_path
41
+ set :foreman_app, -> { fetch(:application) }
42
+ set :foreman_concurrency, 'web=2,worker=1' # optional, default is not set
43
+ set :foreman_log, -> { shared_path.join('log') }
44
+ set :foreman_port, 3000 # optional, default is not set
45
+ set :foreman_user, 'www-data' # optional, default is not set
46
+ ```
47
+
48
+ See [exporting options](http://ddollar.github.io/foreman/#EXPORTING) for an exhaustive list of foreman options.
49
+
50
+ ### Tasks
51
+
52
+ This gem provides the following Capistrano tasks:
53
+
54
+ * `foreman:setup` exports the Procfile and starts application services
55
+ * `foreman:export` exports the Procfile to process management format
56
+ * `foreman:restart` restarts the application services
57
+ * `foreman:start` starts the application services
58
+ * `foreman:stop` stops the application services
59
+
60
+ ## Example
61
+
62
+ A typical setup would look like the following:
63
+
64
+ Have a group-writeable directory under `/etc/init` for the group `deploy` (in this case I call it `sites`) to store the init scripts:
65
+
66
+ ```bash
67
+ sudo mkdir /etc/init/sites
68
+ sudo chown :deploy /etc/init/sites
69
+ sudo chmod g+w /etc/init/sites
70
+ ```
71
+
72
+ And the following configuration in `deploy.rb`:
73
+
74
+ ```ruby
75
+ # Set the app with `sites/` prefix
76
+ set :foreman_app, -> { "sites/#{fetch(:application)}" }
77
+
78
+ # Set user to `deploy`, assuming this is your deploy user
79
+ set :foreman_user, 'deploy'
80
+
81
+ # Set root to `current_path` so exporting only have to be done once.
82
+ set :foreman_flags, "--root=#{current_path}"
83
+ ```
84
+
85
+ Setup your init scripts by running `foreman:setup` after your first deploy.
86
+ From this moment on you only have to run `foreman:setup` when your `Procfile` has changed or when you alter the foreman deploy configuration.
87
+
88
+ Finally you have to instruct Capistrano to run `foreman:restart` after deploy:
89
+
90
+ ```ruby
91
+ # Hook foreman restart after publishing
92
+ after :'deploy:publishing', :'foreman:restart'
93
+ ```
94
+
95
+ ## Notes
96
+
97
+ When using `rbenv`, `rvm`, `chruby` and/or `bundler` don't forget to add `foreman` to the bins list:
98
+
99
+ ```ruby
100
+ fetch(:rbenv_map_bins, []).push 'foreman'
101
+ fetch(:rvm_map_bins, []).push 'foreman'
102
+ fetch(:chruby_map_bins, []).push 'foreman'
103
+ fetch(:bundle_bins, []).push 'foreman'
104
+ ```
105
+
106
+ ## Contributing
107
+
108
+ 1. Fork it
109
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
110
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
111
+ 4. Push to the branch (`git push origin my-new-feature`)
112
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'capistrano-foreman-systemd'
7
+ spec.version = '0.0.4'
8
+ spec.authors = ['Adrian Serafin']
9
+ spec.email = ['adrian@softmad.pl']
10
+ spec.description = %q{Foreman and systemd tasks for Capistrano 3.x}
11
+ spec.summary = %q{Foreman and systemd tasks for Capistrano 3.x}
12
+ spec.homepage = 'https://github.com/aserafin/capistrano-foreman'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'capistrano', '~> 3.4.1'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
24
+ end
File without changes
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/foreman.rake', __FILE__)
@@ -0,0 +1,93 @@
1
+ namespace :foreman do
2
+ desc <<-DESC
3
+ Setup foreman configuration
4
+
5
+ Configurable options are:
6
+
7
+ set :foreman_roles, :all
8
+ set :foreman_export_format, 'upstart'
9
+ set :foreman_export_path, '/etc/init'
10
+ set :foreman_flags, ''
11
+ set :foreman_target_path, release_path
12
+ set :foreman_app, -> { fetch(:application) }
13
+ set :foreman_concurrency, 'web=2,worker=1' # default is not set
14
+ set :foreman_log, -> { shared_path.join('log') }
15
+ set :foreman_port, 3000 # default is not set
16
+ set :foreman_user, 'www-data' # default is not set
17
+ DESC
18
+
19
+ task :setup do
20
+ invoke :'foreman:export'
21
+ invoke :'foreman:enable'
22
+ invoke :'foreman:start'
23
+ end
24
+
25
+ desc "Enables service in systemd"
26
+ task :enable do
27
+ on roles fetch(:foreman_roles) do
28
+ sudo :systemctl, "enable #{fetch(:foreman_app)}.target"
29
+ end
30
+ end
31
+
32
+ desc "Disables service in systemd"
33
+ task :disable do
34
+ on roles fetch(:foreman_roles) do
35
+ sudo :systemctl, "disable #{fetch(:foreman_app)}.target"
36
+ end
37
+ end
38
+
39
+
40
+ desc "Export the Procfile to another process management format"
41
+ task :export do
42
+ on roles fetch(:foreman_roles) do |server|
43
+ execute :mkdir, "-p", fetch(:foreman_export_path) unless test "[ -d #{fetch(:foreman_export_path)} ]"
44
+ within fetch(:foreman_target_path, release_path) do
45
+
46
+ options = {
47
+ app: fetch(:foreman_app),
48
+ log: fetch(:foreman_log)
49
+ }
50
+ options[:concurrency] = fetch(:foreman_concurrency) if fetch(:foreman_concurrency)
51
+ options[:concurrency] = server.properties.foreman_concurrency if server.properties.foreman_concurrency
52
+ options[:port] = fetch(:foreman_port) if fetch(:foreman_port)
53
+ options[:user] = fetch(:foreman_user) if fetch(:foreman_user)
54
+
55
+ execute :foreman, 'export', fetch(:foreman_export_format), fetch(:foreman_export_path),
56
+ options.map{ |k, v| "--#{k}='#{v}'" }, fetch(:foreman_flags)
57
+ end
58
+ end
59
+ end
60
+
61
+ desc "Start the application services"
62
+ task :start do
63
+ on roles fetch(:foreman_roles) do
64
+ sudo :start, fetch(:foreman_app)
65
+ end
66
+ end
67
+
68
+ desc "Stop the application services"
69
+ task :stop do
70
+ on roles fetch(:foreman_roles) do
71
+ sudo :stop, fetch(:foreman_app)
72
+ end
73
+ end
74
+
75
+ desc "Restart the application services"
76
+ task :restart do
77
+ on roles fetch(:foreman_roles) do
78
+ sudo :restart, fetch(:foreman_app)
79
+ end
80
+ end
81
+
82
+ end
83
+
84
+ namespace :load do
85
+ task :defaults do
86
+ set :foreman_roles, :all
87
+ set :foreman_export_format, 'upstart'
88
+ set :foreman_export_path, '/etc/init'
89
+ set :foreman_flags, ''
90
+ set :foreman_app, -> { fetch(:application) }
91
+ set :foreman_log, -> { shared_path.join('log') }
92
+ end
93
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-foreman-systemd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Adrian Serafin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.4.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.4.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Foreman and systemd tasks for Capistrano 3.x
56
+ email:
57
+ - adrian@softmad.pl
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.md
65
+ - README.md
66
+ - Rakefile
67
+ - capistrano-foreman.gemspec
68
+ - lib/capistrano-foreman.rb
69
+ - lib/capistrano/foreman.rb
70
+ - lib/capistrano/tasks/foreman.rake
71
+ homepage: https://github.com/aserafin/capistrano-foreman
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.5.1
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Foreman and systemd tasks for Capistrano 3.x
95
+ test_files: []