capistrano-4ever 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +90 -0
- data/Rakefile +2 -0
- data/capistrano-4ever.gemspec +23 -0
- data/lib/capistrano-forever.rb +0 -0
- data/lib/capistrano/forever.rb +7 -0
- data/lib/capistrano/forever/version.rb +5 -0
- data/lib/capistrano/tasks/forever.rake +89 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cbfabf38a9606124f34ab303cab1bcba79717a1e
|
4
|
+
data.tar.gz: 26013e81c790a4c480fa3afe32cc2ebdb9a888a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3156a91e659dce79bc053960f697a4d3beef706d26af6b731a88804e6963a7880d6dce55cff9cfd902d124989502f5786ac3ad411353a8b86e385e4f7910bfe0
|
7
|
+
data.tar.gz: 1ea1f880c19b02746742a79d0d5dad65dda6ce13790f798b86a523977aa0c8cd1ddd02abb7b989df09365c242bd23a704961aa658db84720be4a1ce91c7f1a1c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Forrest Fleming
|
2
|
+
|
3
|
+
MIT License
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# capistrano-4ever
|
2
|
+
|
3
|
+
This gem provides some Capistrano3 tasks for deploying NodeJS servers using the
|
4
|
+
npm package Forever to make sure that that application runs forever.
|
5
|
+
The gem is named 'capistrano-4ever', as 'capistrano-forever' was taken (thus,
|
6
|
+
perhaps, rendering this gem redundant). In any case, this gem namespaces under
|
7
|
+
'forever' instead of '4ever', and so the two gems are incompatible.
|
8
|
+
|
9
|
+
[Available via RubyGems](https://rubygems.org/gems/capistrano-4ever)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'capistrano-4ever'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
% bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
% gem install capistrano-4ever
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Require in Capfile:
|
30
|
+
```ruby
|
31
|
+
require 'capistrano/forever'
|
32
|
+
```
|
33
|
+
|
34
|
+
### Configuration options to be set in deploy.rb
|
35
|
+
`:forever_env_variables` : Any environmental variables you'd like, as a hash. I recommend setting `NODE_ENV` here.<br>
|
36
|
+
`:forever_path` : Path to globally installed forever binary.<br>
|
37
|
+
`:forever_app` : The application you're deploying.<br>
|
38
|
+
`:forever_target_path` : The target path. Defaults to Capistrano's `release_path`. I recommend that you don't set this.<br>
|
39
|
+
`:forever_flags` : Flags to pass to the forever binary as a string.
|
40
|
+
* NB: **Order is important** here! Ape the order in the example below or play around, but don't be frustrated if something that seems like it should work doesn't. This is due to how the foreman binary parses options.
|
41
|
+
|
42
|
+
### Configuration defaults
|
43
|
+
Configuration symbol | Default
|
44
|
+
---------------|-----------------
|
45
|
+
`:forever_env_variables` | `{}`<br>
|
46
|
+
`:forever_path` | `'forever'` (let `env` take care of pathing)
|
47
|
+
`:forever_app` | `'main.js'`<br>
|
48
|
+
`:forever_target_path` | Capistrano's `release_path`<br>
|
49
|
+
`:forever_flags` | `'--append --uid <forever_app>'`
|
50
|
+
|
51
|
+
### Configuration recommendations
|
52
|
+
I recommend setting:<br>
|
53
|
+
`-l` : So that you can have a shared logfile across deploys<br>
|
54
|
+
`--append` : Append to logfiles and don't die when the logfile exists<br>
|
55
|
+
`--minUptime` : If nothing else, keep NodeJS from complaing that you didn't set it.<br>
|
56
|
+
`--spinSleepTime` : See above<br>
|
57
|
+
`--uid <string>` : Set a custom string so that this gem will be able to stop previously-started instances.<br>
|
58
|
+
|
59
|
+
### Example
|
60
|
+
```ruby
|
61
|
+
set :forever_env_variables, {'NODE_ENV' => "#{fetch(:npm_env)}"}
|
62
|
+
set :forever_path, '/usr/bin/forever'
|
63
|
+
set :forever_app, 'dog-sitting-calendar.js'
|
64
|
+
set :forever_target_path, '/var/www/dogsit'
|
65
|
+
set :forever_flags, [ "-l #{fetch :forever_target_path}/log/forever.log",
|
66
|
+
'--append',
|
67
|
+
'--minUptime 1000',
|
68
|
+
'--spinSleepTime 1000',
|
69
|
+
"--uid '#{fetch :forever_app}'" ].join(' ')
|
70
|
+
```
|
71
|
+
|
72
|
+
### Custom tasks
|
73
|
+
```
|
74
|
+
% bundle exec cap <environment> forever:<task>
|
75
|
+
```
|
76
|
+
* `check` : Check for `forever` binary on deploy target
|
77
|
+
* Displays human-readable output; not for scripting
|
78
|
+
* `start` : Start NodeJS server with forever
|
79
|
+
* `stop`: Stop NodeJS server with forever
|
80
|
+
* `restart` : Restart NodeJS server with forever
|
81
|
+
* `stop_all` : Stop all NodeJS servers managed by forever on target server
|
82
|
+
* `restart_all` : Restart all NodeJS servers managed by forever on target server
|
83
|
+
|
84
|
+
## Contributing
|
85
|
+
|
86
|
+
1. Fork it ( https://github.com/oversee-ffleming/capistrano-forever/fork )
|
87
|
+
2. Create your feature branch (`git checkout -b new-feature`)
|
88
|
+
3. Commit your changes (`git commit -am 'Added a neat feature!'`)
|
89
|
+
4. Push to the branch (`git push origin new-feature`)
|
90
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/forever/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capistrano-4ever"
|
8
|
+
spec.version = Capistrano::Forever::VERSION
|
9
|
+
spec.authors = ["Forrest Fleming"]
|
10
|
+
spec.email = ["ffleming@oversee.net"]
|
11
|
+
spec.summary = 'Capistrano3 tasks for deploying NodeJS servers via forever'
|
12
|
+
spec.description = 'Provides forever: namespace with several tasks for deploying NodeJS server via forever'
|
13
|
+
spec.homepage = "https://github.com/oversee-ffleming/capistrano-forever"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
File without changes
|
@@ -0,0 +1,89 @@
|
|
1
|
+
namespace :forever do
|
2
|
+
def default_forever_path
|
3
|
+
'forever'
|
4
|
+
end
|
5
|
+
|
6
|
+
def default_forever_app
|
7
|
+
'main.js'
|
8
|
+
end
|
9
|
+
|
10
|
+
def default_forever_flags
|
11
|
+
"-a --uid cap-forever-#{fetch(:forever_app, default_forever_app)}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_target_path
|
15
|
+
release_path
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Checks to see that forever is installed globally on the target machines'
|
19
|
+
task :check do
|
20
|
+
on roles :app do
|
21
|
+
exists = test("[ -f #{fetch(:forever_path, default_forever_path)} ]")
|
22
|
+
forever_check = "Forever is not installed to #{fetch(:forever_path, default_forever_path)}"
|
23
|
+
if exists
|
24
|
+
can_execute = test("[ -x #{fetch(:forever_path, default_forever_path)} ]")
|
25
|
+
forever_check = "Forever is installed to #{fetch(:forever_path, default_forever_path)}"
|
26
|
+
forever_check << " #{can_execute ? 'and is' : 'but isn\'t'} executable by #{fetch :user}"
|
27
|
+
end
|
28
|
+
puts forever_check
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Starts the server process via forever'
|
33
|
+
task :start do
|
34
|
+
on roles :app do
|
35
|
+
within fetch(:forever_target_path, default_target_path) do
|
36
|
+
with fetch(:forever_env_variables, {}) do
|
37
|
+
execute fetch(:forever_path, default_forever_path), fetch(:forever_flags, default_forever_flags), 'start', fetch(:forever_app, default_forever_app)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Stops the server process via forever'
|
44
|
+
task :stop do
|
45
|
+
on roles :app do
|
46
|
+
within fetch(:forever_target_path, default_target_path) do
|
47
|
+
with fetch(:forever_env_variables, {}) do
|
48
|
+
begin
|
49
|
+
execute fetch(:forever_path, default_forever_path), fetch(:forever_flags, default_forever_flags), 'stop', fetch(:forever_app, default_forever_app)
|
50
|
+
rescue => e
|
51
|
+
raise e unless e.to_s.include? 'cannot find process with id'
|
52
|
+
puts "Forever: Couldn't stop #{fetch(:forever_app, default_forever_app)} - process not found"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'Restarts the server process via forever'
|
60
|
+
task :restart do
|
61
|
+
on roles :app do
|
62
|
+
invoke 'forever:stop'
|
63
|
+
invoke 'forever:start'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
desc 'Stops all server processes managed by forever'
|
68
|
+
task :stop_all do
|
69
|
+
on roles :app do
|
70
|
+
within fetch(:forever_target_path, default_target_path) do
|
71
|
+
with fetch(:forever_env_variables, {}) do
|
72
|
+
execute fetch(:forever_path, default_forever_path), 'stopall'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'Restarts all server processes managed by forever'
|
79
|
+
task :restart_all do
|
80
|
+
on roles :app do
|
81
|
+
within fetch(:forever_target_path, default_target_path) do
|
82
|
+
with fetch(:forever_env_variables, {}) do
|
83
|
+
execute fetch(:forever_path, default_forever_path), 'restartall'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-4ever
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Forrest Fleming
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: 'Provides forever: namespace with several tasks for deploying NodeJS
|
42
|
+
server via forever'
|
43
|
+
email:
|
44
|
+
- ffleming@oversee.net
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- capistrano-4ever.gemspec
|
55
|
+
- lib/capistrano-forever.rb
|
56
|
+
- lib/capistrano/forever.rb
|
57
|
+
- lib/capistrano/forever/version.rb
|
58
|
+
- lib/capistrano/tasks/forever.rake
|
59
|
+
homepage: https://github.com/oversee-ffleming/capistrano-forever
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.2.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Capistrano3 tasks for deploying NodeJS servers via forever
|
83
|
+
test_files: []
|