cap_crontab 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +29 -0
- data/MIT_LICENSE +22 -0
- data/README.rdoc +65 -0
- data/VERSION +1 -0
- data/cap_crontab.gemspec +19 -0
- data/lib/cap_crontab.rb +8 -0
- data/recipes/cap_crontab.rb +23 -0
- metadata +57 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
cap_crontab*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cap_crontab (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
capistrano (2.14.1)
|
10
|
+
highline
|
11
|
+
net-scp (>= 1.0.0)
|
12
|
+
net-sftp (>= 2.0.0)
|
13
|
+
net-ssh (>= 2.0.14)
|
14
|
+
net-ssh-gateway (>= 1.1.0)
|
15
|
+
highline (1.6.15)
|
16
|
+
net-scp (1.0.4)
|
17
|
+
net-ssh (>= 1.99.1)
|
18
|
+
net-sftp (2.0.5)
|
19
|
+
net-ssh (>= 2.0.9)
|
20
|
+
net-ssh (2.6.3)
|
21
|
+
net-ssh-gateway (1.1.0)
|
22
|
+
net-ssh (>= 1.99.1)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
cap_crontab!
|
29
|
+
capistrano
|
data/MIT_LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2009 Scott Taylor (smtlaissezfaire) <scott@railsnewbie.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
= CAP CRONTAB INSTALLER
|
2
|
+
|
3
|
+
Capistrano recipe for installing crontabs from the config/crontabs
|
4
|
+
directory in your application. Extremely simple, but flexible. Crontab files
|
5
|
+
are evaluated as ERB templates and have access to all capistrano variables.
|
6
|
+
|
7
|
+
== INSTALLATION
|
8
|
+
|
9
|
+
# in Gemfile:
|
10
|
+
gem 'cap_crontab'
|
11
|
+
|
12
|
+
$ bundle install
|
13
|
+
|
14
|
+
# in your config/deploy.rb:
|
15
|
+
require 'cap_crontab'
|
16
|
+
|
17
|
+
Create a directory in config/ named crontabs/ and create crontab files for each
|
18
|
+
environment where you want to install a crontab:
|
19
|
+
|
20
|
+
config/
|
21
|
+
crontabs/
|
22
|
+
production
|
23
|
+
staging
|
24
|
+
|
25
|
+
Example crontab file:
|
26
|
+
|
27
|
+
# Do some stuff once an hour
|
28
|
+
0 * * * * RAILS_ENV=<%= rails_env %> ruby <%= current_path %>/script/cron/do_stuff.rb
|
29
|
+
# Do some other stuff every twenty minutes
|
30
|
+
*/20 * * * * RAILS_ENV=<%= rails_env %> ruby <%= current_path %>/script/cron/do_other_stuff.rb
|
31
|
+
|
32
|
+
This file is evaluated as an ERB template and all of the existing capistrano
|
33
|
+
variables are available for use.
|
34
|
+
|
35
|
+
In your deploy file add the :crontab => true flag on the server(s) where you'd
|
36
|
+
like the crontab installed:
|
37
|
+
|
38
|
+
task :staging do
|
39
|
+
set :env, "staging"
|
40
|
+
role :web, 'example.com'
|
41
|
+
role :app, 'example.com', :crontab => true
|
42
|
+
role :db, 'example.com', :primary => true
|
43
|
+
end
|
44
|
+
|
45
|
+
Add an after hook to install the crontab on the server on deploy:
|
46
|
+
|
47
|
+
after "deploy:symlink", "crontab:install"
|
48
|
+
|
49
|
+
== USAGE
|
50
|
+
|
51
|
+
If you use the 'after' hook the crontab will be installed on each
|
52
|
+
deploy.
|
53
|
+
|
54
|
+
Otherwise to install it separately:
|
55
|
+
|
56
|
+
cap crontab:install
|
57
|
+
|
58
|
+
To show the crontab after installing it:
|
59
|
+
|
60
|
+
cap crontab:show
|
61
|
+
|
62
|
+
== COPYRIGHT
|
63
|
+
|
64
|
+
Copyright (c) 2010 Conor Hunt <conor.hunt AT gmail>
|
65
|
+
Released under the MIT license
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.2
|
data/cap_crontab.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: 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 |gem|
|
6
|
+
gem.name = "cap_crontab"
|
7
|
+
gem.version = File.read("VERSION")
|
8
|
+
gem.authors = ["Conor Hunt", "Scott Taylor"]
|
9
|
+
gem.email = ["scott@railsnewbie.com"]
|
10
|
+
gem.description = %q{Install a crontab through cap}
|
11
|
+
gem.summary = <<-HERE
|
12
|
+
Capistrano recipe for installing crontabs from the config/crontabs
|
13
|
+
directory in your application. Extremely simple, but flexible. Crontab files
|
14
|
+
are evaluated as ERB templates and have access to all capistrano variables.
|
15
|
+
HERE
|
16
|
+
gem.homepage = "http://github.com/smtlaissezfaire/cap_crontab"
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
data/lib/cap_crontab.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
namespace :crontab do
|
4
|
+
desc "Show the existing installed crontab"
|
5
|
+
task :show, :only => { :crontab => true } do
|
6
|
+
puts capture("crontab -l")
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Install a new crontab on any servers that have :crontab => true"
|
10
|
+
task :install, :only => { :crontab => true } do
|
11
|
+
crontab_file = "#{current_path}/config/crontabs/#{env}"
|
12
|
+
cron_template = capture("test -e #{crontab_file} && cat #{crontab_file} || echo 'none'")
|
13
|
+
|
14
|
+
if cron_template and cron_template.strip != "none"
|
15
|
+
buffer = ERB.new(cron_template).result(binding)
|
16
|
+
buffer = buffer.gsub(%r{\r\n?},"\n") # Convert line endings to unix
|
17
|
+
put buffer, "#{crontab_file}_crontab_out"
|
18
|
+
run "crontab #{crontab_file}_crontab_out"
|
19
|
+
else
|
20
|
+
puts "No crontab installed. No file found at '#{crontab_file}'"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cap_crontab
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Conor Hunt
|
9
|
+
- Scott Taylor
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-01-20 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: Install a crontab through cap
|
16
|
+
email:
|
17
|
+
- scott@railsnewbie.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- MIT_LICENSE
|
26
|
+
- README.rdoc
|
27
|
+
- VERSION
|
28
|
+
- cap_crontab.gemspec
|
29
|
+
- lib/cap_crontab.rb
|
30
|
+
- recipes/cap_crontab.rb
|
31
|
+
homepage: http://github.com/smtlaissezfaire/cap_crontab
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.8.24
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: Capistrano recipe for installing crontabs from the config/crontabs directory
|
55
|
+
in your application. Extremely simple, but flexible. Crontab files are evaluated
|
56
|
+
as ERB templates and have access to all capistrano variables.
|
57
|
+
test_files: []
|