rsm 0.1.beta4 → 0.1.rc1
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/CHANGES.md +6 -0
- data/README.md +9 -7
- data/VERSION +1 -1
- data/bin/rsm +0 -0
- data/lib/rsm/base.rb +8 -3
- data/lib/rsm/runner.rb +118 -9
- data/lib/rsm.rb +0 -11
- data/lib/tasks/unicorn/start.rb +18 -0
- data/lib/tasks/unicorn/stop.rb +12 -0
- data/rsm.gemspec +0 -1
- metadata +9 -9
- data/lib/rsm/unicorn.rb +0 -16
- /data/lib/{rsm → tasks}/install/nginx.rb +0 -0
- /data/lib/{rsm → tasks}/install/rails.rb +0 -0
- /data/templates/{nginx-unicorn.conf.erb → rsm/install/nginx/nginx-unicorn.conf.erb} +0 -0
- /data/templates/{unicorn.rb.erb → rsm/install/rails/unicorn.rb.erb} +0 -0
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -7,16 +7,12 @@ RSM created for make easier some actons on server like:
|
|
7
7
|
* manipulation of files
|
8
8
|
* running commands
|
9
9
|
|
10
|
-
and other Rails application tasks.
|
11
|
-
|
12
10
|
This version can:
|
13
11
|
|
14
12
|
* create Nginx virtual server config from template
|
15
|
-
* enable Nginx virtual server config
|
13
|
+
* automaticly enable Nginx virtual server config
|
16
14
|
* clone from Git repo or download and unpack Rails application from TGZ or TBZ2 archive
|
17
|
-
*
|
18
|
-
* create Unicorn config from template
|
19
|
-
* run unicorn server
|
15
|
+
* start and stop unicorn server
|
20
16
|
|
21
17
|
Homepage
|
22
18
|
--------
|
@@ -43,7 +39,13 @@ Install from RubyGems:
|
|
43
39
|
Ussage
|
44
40
|
-----
|
45
41
|
|
46
|
-
|
42
|
+
List avalable tasks:
|
43
|
+
|
44
|
+
$ rsm -T
|
45
|
+
|
46
|
+
Help for certain task:
|
47
|
+
|
48
|
+
$ rsm help TASK
|
47
49
|
|
48
50
|
Documentation
|
49
51
|
-------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.rc1
|
data/bin/rsm
CHANGED
File without changes
|
data/lib/rsm/base.rb
CHANGED
@@ -7,11 +7,16 @@ module Rsm
|
|
7
7
|
|
8
8
|
argument :name
|
9
9
|
|
10
|
-
class_option :apps_root, :
|
11
|
-
class_option :capistrano, :
|
10
|
+
class_option :apps_root, :default => "/var/www", :aliases => "-r", :desc => "Rails apps root"
|
11
|
+
class_option :capistrano, :default => false, :aliases => "-c", :desc => "Application's Capistrano stage"
|
12
12
|
|
13
|
+
|
14
|
+
def self.template_path
|
15
|
+
Thor::Util.snake_case(name.to_s).squeeze(":").gsub(":", "/")
|
16
|
+
end
|
17
|
+
|
13
18
|
def self.source_root
|
14
|
-
File.expand_path(
|
19
|
+
File.expand_path("../../../templates/#{template_path}", __FILE__)
|
15
20
|
end
|
16
21
|
|
17
22
|
def application_root
|
data/lib/rsm/runner.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/group'
|
3
|
+
require 'thor/util'
|
4
|
+
|
1
5
|
module Rsm
|
6
|
+
class Error < Thor::Error; end
|
7
|
+
|
2
8
|
class Runner < Thor
|
9
|
+
map '-T' => :list, '-v' => :version
|
10
|
+
#
|
3
11
|
include Thor::Actions
|
4
12
|
|
5
13
|
desc "version", "RSM gem version"
|
@@ -8,18 +16,119 @@ module Rsm
|
|
8
16
|
say "RSM version #{Rsm::VERSION}"
|
9
17
|
end
|
10
18
|
|
11
|
-
|
12
|
-
|
19
|
+
# If a task is not found on Thor::Runner, method missing is invoked and
|
20
|
+
# Thor::Runner is then responsable for finding the task in all classes.
|
21
|
+
#
|
22
|
+
def method_missing(meth, *args)
|
23
|
+
meth = meth.to_s
|
24
|
+
initialize_thorfiles(meth)
|
25
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
|
26
|
+
args.unshift(task) if task
|
27
|
+
klass.start(args, :shell => self.shell)
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "list [SEARCH]", "List the available thor tasks (--substring means .*SEARCH)"
|
31
|
+
method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean
|
32
|
+
def list(search="")
|
33
|
+
initialize_thorfiles
|
34
|
+
|
35
|
+
search = ".*#{search}" if options["substring"]
|
36
|
+
search = /^#{search}.*/i
|
37
|
+
group = options[:group] || "standard"
|
38
|
+
|
39
|
+
klasses = Thor::Base.subclasses.select do |k|
|
40
|
+
(options[:all] || k.group == group) && k.namespace =~ search
|
41
|
+
end
|
42
|
+
|
43
|
+
display_klasses(false, false, klasses)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Override Thor#help so it can give information about any class and any method.
|
47
|
+
#
|
48
|
+
def help(meth = nil)
|
49
|
+
if meth && !self.respond_to?(meth)
|
50
|
+
initialize_thorfiles(meth)
|
51
|
+
klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
|
52
|
+
klass.start(["-h", task].compact, :shell => self.shell)
|
53
|
+
else
|
54
|
+
super
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
13
59
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
60
|
+
def self.banner(task, all = false, subcommand = false)
|
61
|
+
"rsm " + task.formatted_usage(self, all, subcommand)
|
62
|
+
end
|
63
|
+
|
64
|
+
def thor_root
|
65
|
+
File.expand_path("../../tasks", __FILE__)
|
18
66
|
end
|
67
|
+
|
68
|
+
def thorfiles(relevant_to=nil, skip_lookup=false)
|
69
|
+
Dir["#{thor_root}/**/*.rb"]
|
70
|
+
end
|
71
|
+
|
72
|
+
# Load the thorfiles. If relevant_to is supplied, looks for specific files
|
73
|
+
# in the thor_root instead of loading them all.
|
74
|
+
#
|
75
|
+
# By default, it also traverses the current path until find Thor files, as
|
76
|
+
# described in thorfiles. This look up can be skipped by suppliying
|
77
|
+
# skip_lookup true.
|
78
|
+
#
|
79
|
+
def initialize_thorfiles(relevant_to=nil, skip_lookup=false)
|
80
|
+
thorfiles(relevant_to, skip_lookup).each do |f|
|
81
|
+
require f unless Thor::Base.subclass_files.keys.include?(File.expand_path(f))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Display information about the given klasses. If with_module is given,
|
86
|
+
# it shows a table with information extracted from the yaml file.
|
87
|
+
#
|
88
|
+
def display_klasses(with_modules=false, show_internal=false, klasses=Thor::Base.subclasses)
|
89
|
+
klasses -= [Thor, Thor::Group, Rsm::Runner, Rsm::Base] unless show_internal
|
90
|
+
|
91
|
+
raise Error, "No Thor tasks available" if klasses.empty?
|
92
|
+
# show_modules if with_modules && !thor_yaml.empty?
|
93
|
+
|
94
|
+
list = Hash.new { |h,k| h[k] = [] }
|
95
|
+
groups = klasses.select { |k| k.ancestors.include?(Thor::Group) }
|
96
|
+
|
97
|
+
# Get classes which inherit from Thor
|
98
|
+
(klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_tasks(false) }
|
99
|
+
|
100
|
+
# Get classes which inherit from Thor::Base
|
101
|
+
groups.map! { |k| k.printable_tasks(false).first }
|
102
|
+
list["root"] = groups
|
103
|
+
|
104
|
+
# Order namespaces with default coming first
|
105
|
+
list = list.sort{ |a,b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') }
|
106
|
+
list.each { |n, tasks| display_tasks(n, tasks) unless tasks.empty? }
|
107
|
+
end
|
108
|
+
|
109
|
+
def display_tasks(namespace, list) #:nodoc:
|
110
|
+
list.sort!{ |a,b| a[0] <=> b[0] }
|
111
|
+
|
112
|
+
say shell.set_color(namespace, :blue, true)
|
113
|
+
say "-" * namespace.size
|
114
|
+
|
115
|
+
print_table(list, :truncate => true)
|
116
|
+
say
|
117
|
+
end
|
118
|
+
|
119
|
+
def show_modules #:nodoc:
|
120
|
+
info = []
|
121
|
+
labels = ["Modules", "Namespaces"]
|
122
|
+
|
123
|
+
info << labels
|
124
|
+
info << [ "-" * labels[0].size, "-" * labels[1].size ]
|
125
|
+
|
126
|
+
thor_yaml.each do |name, hash|
|
127
|
+
info << [ name, hash[:namespaces].join(", ") ]
|
128
|
+
end
|
19
129
|
|
20
|
-
|
21
|
-
|
22
|
-
invoke Rsm::Unicorn
|
130
|
+
print_table info
|
131
|
+
say ""
|
23
132
|
end
|
24
133
|
end
|
25
134
|
end
|
data/lib/rsm.rb
CHANGED
@@ -1,16 +1,5 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'thor'
|
3
|
-
require 'thor/group'
|
4
|
-
require 'thor/util'
|
5
|
-
|
6
1
|
module Rsm
|
7
2
|
autoload :Actions, 'rsm/actions'
|
8
3
|
autoload :Runner, 'rsm/runner'
|
9
4
|
autoload :Base, 'rsm/base'
|
10
|
-
autoload :Unicorn, 'rsm/unicorn'
|
11
|
-
|
12
|
-
module Install
|
13
|
-
autoload :Nginx, 'rsm/install/nginx'
|
14
|
-
autoload :Rails, 'rsm/install/rails'
|
15
|
-
end
|
16
5
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rsm
|
2
|
+
module Unicorn
|
3
|
+
class Start < Rsm::Base
|
4
|
+
class_option :environment, :aliases => "-e", :default => "production"
|
5
|
+
|
6
|
+
def unicorn_rails
|
7
|
+
rvmrc = application_root.join(".rvmrc")
|
8
|
+
if rvmrc.exist?
|
9
|
+
ruby_cmd = File.new(rvmrc).readline.strip + " exec"
|
10
|
+
else
|
11
|
+
ruby_cmd = "#{Thor::Util.ruby_command} -S"
|
12
|
+
end
|
13
|
+
run "#{ruby_cmd} unicorn_rails -D -E #{options[:environment]} -c #{application_root.join("config", "unicorn.rb")}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/rsm.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.rc1
|
5
5
|
prerelease: 4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-08-31 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &19351848 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19351848
|
25
25
|
description: Thor tasks for rapid deployment new rails apps on server
|
26
26
|
email: a.ulyanitsky@gmail.com
|
27
27
|
executables:
|
@@ -43,14 +43,15 @@ files:
|
|
43
43
|
- lib/rsm.rb
|
44
44
|
- lib/rsm/actions.rb
|
45
45
|
- lib/rsm/base.rb
|
46
|
-
- lib/rsm/install/nginx.rb
|
47
|
-
- lib/rsm/install/rails.rb
|
48
46
|
- lib/rsm/runner.rb
|
49
|
-
- lib/rsm/unicorn.rb
|
50
47
|
- lib/rsm/version.rb
|
48
|
+
- lib/tasks/install/nginx.rb
|
49
|
+
- lib/tasks/install/rails.rb
|
50
|
+
- lib/tasks/unicorn/start.rb
|
51
|
+
- lib/tasks/unicorn/stop.rb
|
51
52
|
- rsm.gemspec
|
52
|
-
- templates/nginx-unicorn.conf.erb
|
53
|
-
- templates/unicorn.rb.erb
|
53
|
+
- templates/rsm/install/nginx/nginx-unicorn.conf.erb
|
54
|
+
- templates/rsm/install/rails/unicorn.rb.erb
|
54
55
|
homepage: https://github.com/asux/rsm
|
55
56
|
licenses:
|
56
57
|
- MIT
|
@@ -77,7 +78,6 @@ requirements:
|
|
77
78
|
- A coreutils installed
|
78
79
|
- A Git installed
|
79
80
|
- A Nginx installed
|
80
|
-
- You must have super-user access
|
81
81
|
rubyforge_project:
|
82
82
|
rubygems_version: 1.8.6
|
83
83
|
signing_key:
|
data/lib/rsm/unicorn.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Rsm
|
2
|
-
class Unicorn < Base
|
3
|
-
|
4
|
-
class_option :environment, :aliases => "-e", :default => "production"
|
5
|
-
|
6
|
-
def unicorn_rails
|
7
|
-
rvmrc = application_root.join(".rvmrc")
|
8
|
-
if rvmrc.exist?
|
9
|
-
ruby_cmd = File.new(rvmrc).readline.strip + " exec"
|
10
|
-
else
|
11
|
-
ruby_cmd = "#{Thor::Util.ruby_command} -S"
|
12
|
-
end
|
13
|
-
run "#{ruby_cmd} unicorn_rails -D -E #{options[:environment]} -c #{application_root.join("config", "unicorn.rb")}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|