simonmenke-shuttle 0.1.07
Sign up to get free protection for your applications and to get access to all the features.
- data/app_generators/engine/engine_generator.rb +39 -0
- data/app_generators/engine/templates/config/routes.rb +2 -0
- data/app_generators/engine/templates/init.rb +1 -0
- data/app_generators/engine/templates/lib/engine.rb +1 -0
- data/app_generators/engine/templates/rails/init.rb +1 -0
- data/bin/shuttle +20 -0
- data/lib/rubygems_plugin.rb +1 -0
- data/lib/shuttle/actor/actions.rb +76 -0
- data/lib/shuttle/actor.rb +23 -0
- data/lib/shuttle/actors/apache_actor.rb +56 -0
- data/lib/shuttle/actors/base_actor.rb +276 -0
- data/lib/shuttle/actors/mysql_actor.rb +20 -0
- data/lib/shuttle/actors/passenger_actor.rb +19 -0
- data/lib/shuttle/actors/plesk_actor.rb +210 -0
- data/lib/shuttle/actors/sqlite3_actor.rb +44 -0
- data/lib/shuttle/app_runner.rb +118 -0
- data/lib/shuttle/apps/dev.rb +27 -0
- data/lib/shuttle/apps/engines.rb +33 -0
- data/lib/shuttle/apps/jobs.rb +35 -0
- data/lib/shuttle/apps/satellite.rb +32 -0
- data/lib/shuttle/apps/server.rb +70 -0
- data/lib/shuttle/client/auth_token.rb +98 -0
- data/lib/shuttle/client.rb +48 -0
- data/lib/shuttle/exception_handler.rb +53 -0
- data/lib/shuttle/extentions/rubygems_plugin.rb +27 -0
- data/lib/shuttle/extentions/thor_extentions.rb +32 -0
- data/lib/shuttle/job_queue.rb +199 -0
- data/lib/shuttle/satellite/actions.rb +35 -0
- data/lib/shuttle/satellite/dependency_loader.rb +79 -0
- data/lib/shuttle/satellite/persistence.rb +50 -0
- data/lib/shuttle/satellite.rb +49 -0
- data/lib/shuttle/server/daemon.rb +85 -0
- data/lib/shuttle/server/proxy.rb +25 -0
- data/lib/shuttle/server/security.rb +113 -0
- data/lib/shuttle/server.rb +113 -0
- data/lib/shuttle/system/config.rb +36 -0
- data/lib/shuttle/system/helper.rb +21 -0
- data/lib/shuttle/system/options.rb +79 -0
- data/lib/shuttle/system/process_user.rb +75 -0
- data/lib/shuttle/system/satellites.rb +44 -0
- data/lib/shuttle/system/shell.rb +80 -0
- data/lib/shuttle/system.rb +159 -0
- data/lib/shuttle/systems/centos_plesk_system.rb +28 -0
- data/lib/shuttle/systems/macports_system.rb +14 -0
- data/lib/shuttle.rb +82 -0
- data/spec/actor/actions_spec.rb +13 -0
- data/spec/spec_helper.rb +1 -0
- metadata +129 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
|
2
|
+
module Shuttle
|
3
|
+
class System
|
4
|
+
include DRbUndumped
|
5
|
+
|
6
|
+
autoload :Shell, File.dirname(__FILE__)+'/system/shell'
|
7
|
+
autoload :Config, File.dirname(__FILE__)+'/system/config'
|
8
|
+
autoload :Helper, File.dirname(__FILE__)+'/system/helper'
|
9
|
+
autoload :Options, File.dirname(__FILE__)+'/system/options'
|
10
|
+
autoload :Satellites, File.dirname(__FILE__)+'/system/satellites'
|
11
|
+
autoload :ProcessUser, File.dirname(__FILE__)+'/system/process_user'
|
12
|
+
|
13
|
+
include Shuttle::System::Shell
|
14
|
+
include Shuttle::System::Config
|
15
|
+
include Shuttle::System::Helper
|
16
|
+
include Shuttle::System::Options
|
17
|
+
include Shuttle::System::Satellites
|
18
|
+
include Shuttle::System::ProcessUser
|
19
|
+
|
20
|
+
# get the shared system. this will also set the shared system if you pass a new system as its argument.
|
21
|
+
def self.shared(system=nil)
|
22
|
+
@system = system if system
|
23
|
+
@system
|
24
|
+
end
|
25
|
+
|
26
|
+
# load the shared system
|
27
|
+
def self.load!(root=nil)
|
28
|
+
@system = new(root)
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(root=nil)
|
32
|
+
unless root
|
33
|
+
if get_user_name == 'root'
|
34
|
+
root = Shuttle::DEFAULT_ROOT_SYSTEM_DIR
|
35
|
+
else
|
36
|
+
root = Shuttle::DEFAULT_USER_SYSTEM_DIR
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
@root = File.expand_path(root)
|
41
|
+
@actors = []
|
42
|
+
@options = {}
|
43
|
+
@option_descriptors = []
|
44
|
+
@satellite_options = {}
|
45
|
+
@satellite_option_descriptors = []
|
46
|
+
|
47
|
+
system_file = self.path('system.rb')
|
48
|
+
unless File.file? system_file
|
49
|
+
Shuttle.log "No system file found (#{system_file})"
|
50
|
+
exit(1)
|
51
|
+
end
|
52
|
+
|
53
|
+
Shuttle::ExceptionHandler.setup(self.path('ServerNormal.log'), self.path('ServerError.log'))
|
54
|
+
|
55
|
+
use :BaseActor
|
56
|
+
self.instance_eval File.read(system_file)
|
57
|
+
self.resolve_options!
|
58
|
+
end
|
59
|
+
|
60
|
+
attr_accessor :current_satellite, :root
|
61
|
+
|
62
|
+
def queue
|
63
|
+
@queue ||= Shuttle::JobQueue.new
|
64
|
+
end
|
65
|
+
|
66
|
+
def path(*args)
|
67
|
+
File.join(@root, *args)
|
68
|
+
end
|
69
|
+
|
70
|
+
def install_satellite(domain)
|
71
|
+
self.queue.enqueue("install new satellite #{domain}", :domain => domain) do |options|
|
72
|
+
satellite = Shuttle::Satellite.new(options[:domain])
|
73
|
+
|
74
|
+
run_action_on :install_satellite, satellite
|
75
|
+
run_action_on :link_satellite, satellite
|
76
|
+
save_satellite! satellite
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def uninstall_satellite(satellite)
|
81
|
+
if satellite
|
82
|
+
self.queue.enqueue("uninstall #{satellite.domain}", :satellite => satellite) do |options|
|
83
|
+
run_action_on :uninstall_satellite, options[:satellite]
|
84
|
+
destroy_satellite! options[:satellite]
|
85
|
+
end
|
86
|
+
else
|
87
|
+
false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def install_engine(satellite, name, options={})
|
92
|
+
if satellite
|
93
|
+
self.queue.enqueue("install #{satellite.domain}: #{name} #{options.inspect}",
|
94
|
+
:satellite => satellite, :name => name, :options => options) do |options|
|
95
|
+
|
96
|
+
satellite, name, options = options[:satellite], options[:name], options[:options]
|
97
|
+
ensure_presence_of_gem(name, options)
|
98
|
+
if satellite.add_engine(name, options)
|
99
|
+
run_action_on :install_engine, satellite
|
100
|
+
run_action_on :link_satellite, satellite
|
101
|
+
save_satellite! satellite
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
else
|
106
|
+
false
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def update_engine(satellite, name, options={})
|
111
|
+
if satellite
|
112
|
+
self.queue.enqueue("update #{satellite.domain}: #{name} #{options.inspect}",
|
113
|
+
:satellite => satellite, :name => name, :options => options) do |options|
|
114
|
+
|
115
|
+
satellite, name, options = options[:satellite], options[:name], options[:options]
|
116
|
+
ensure_presence_of_gem(name, options)
|
117
|
+
if satellite.update_engine(name, options)
|
118
|
+
run_action_on :update_engine, satellite
|
119
|
+
run_action_on :link_satellite, satellite
|
120
|
+
save_satellite! satellite
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
else
|
125
|
+
false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def uninstall_engine(satellite, name)
|
130
|
+
if satellite
|
131
|
+
self.queue.enqueue("uninstall #{satellite.domain}: #{name}",
|
132
|
+
:satellite => satellite, :name => name) do |options|
|
133
|
+
|
134
|
+
satellite, name = options[:satellite], options[:name]
|
135
|
+
if satellite.remove_engine(name)
|
136
|
+
run_action_on :uninstall_engine, satellite
|
137
|
+
run_action_on :link_satellite, satellite
|
138
|
+
save_satellite! satellite
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
else
|
143
|
+
false
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
|
149
|
+
def run_action_on(action, satellite)
|
150
|
+
resolve_options_with satellite do
|
151
|
+
actors = @actors.collect { |actor_klass| actor_klass.new(self, satellite) }
|
152
|
+
actors.each { |actor| actor.run_callbacks_in_fase! action, :before }
|
153
|
+
actors.each { |actor| actor.run_callbacks_in_fase! action, :on }
|
154
|
+
actors.each { |actor| actor.run_callbacks_in_fase! action, :after }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
use :PassengerActor
|
2
|
+
use :PleskActor
|
3
|
+
|
4
|
+
apachectl_path { '/opt/local/apache2/bin/apachectl' }
|
5
|
+
ruby_path { '/usr/bin/ruby' }
|
6
|
+
gem_path { '/usr/bin/gem' }
|
7
|
+
plesk_path { '/usr/bin/gem' }
|
8
|
+
|
9
|
+
web_user { |s| s.domain.gsub(/[^a-zA-Z0-9]+/, '_') }
|
10
|
+
web_group { 'psacln' }
|
11
|
+
|
12
|
+
plesk_root { |s| "/var/www/vhost" }
|
13
|
+
|
14
|
+
satellite_root do |s|
|
15
|
+
if s.subdomain?
|
16
|
+
"#{plesk_root}/#{s.basedomain}/subdomains/#{s.subdomain}/satellite"
|
17
|
+
else
|
18
|
+
"#{plesk_root}/#{s.domain}/satellite"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
shared_root do |s|
|
23
|
+
if s.subdomain?
|
24
|
+
"#{plesk_root}/#{s.basedomain}/subdomains/#{s.subdomain}/shared"
|
25
|
+
else
|
26
|
+
"#{plesk_root}/#{s.domain}/shared"
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
use :PassengerActor
|
2
|
+
use :ApacheActor
|
3
|
+
use :MysqlActor
|
4
|
+
|
5
|
+
apachectl_path { '/opt/local/apache2/bin/apachectl' }
|
6
|
+
ruby_path { '/opt/local/bin/ruby' }
|
7
|
+
gem_path { '/opt/local/bin/gem' }
|
8
|
+
|
9
|
+
|
10
|
+
web_user { 'www' }
|
11
|
+
web_group { 'www' }
|
12
|
+
|
13
|
+
satellite_root { |s| "/opt/local/var/www/#{s.domain}/satellite" }
|
14
|
+
shared_root { |s| "/opt/local/var/www/#{s.domain}/shared" }
|
data/lib/shuttle.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__)+'/shuttle/extentions/rubygems_plugin'
|
4
|
+
|
5
|
+
autoload :DRbUndumped, 'drb'
|
6
|
+
autoload :FileUtils, 'fileutils'
|
7
|
+
|
8
|
+
module Shuttle
|
9
|
+
base = File.expand_path(File.dirname(__FILE__))
|
10
|
+
|
11
|
+
autoload :Actor, (base+'/shuttle/actor')
|
12
|
+
autoload :Server, (base+'/shuttle/server')
|
13
|
+
autoload :Client, (base+'/shuttle/client')
|
14
|
+
autoload :System, (base+'/shuttle/system')
|
15
|
+
autoload :JobQueue, (base+'/shuttle/job_queue')
|
16
|
+
autoload :Satellite, (base+'/shuttle/satellite')
|
17
|
+
autoload :AppRunner, (base+'/shuttle/app_runner')
|
18
|
+
autoload :ExceptionHandler, (base+'/shuttle/exception_handler')
|
19
|
+
|
20
|
+
module Actors
|
21
|
+
base = File.expand_path(File.dirname(__FILE__))
|
22
|
+
|
23
|
+
autoload :BaseActor, (base+'/shuttle/actors/base_actor')
|
24
|
+
autoload :MysqlActor, (base+'/shuttle/actors/mysql_actor')
|
25
|
+
autoload :PleskActor, (base+'/shuttle/actors/plesk_actor')
|
26
|
+
autoload :ApacheActor, (base+'/shuttle/actors/apache_actor')
|
27
|
+
autoload :Sqlite3Actor, (base+'/shuttle/actors/sqlite3_actor')
|
28
|
+
autoload :PassengerActor, (base+'/shuttle/actors/passenger_actor')
|
29
|
+
end
|
30
|
+
|
31
|
+
module Apps
|
32
|
+
base = File.expand_path(File.dirname(__FILE__))
|
33
|
+
|
34
|
+
autoload :Dev, (base+'/shuttle/apps/dev')
|
35
|
+
autoload :Jobs, (base+'/shuttle/apps/jobs')
|
36
|
+
autoload :Server, (base+'/shuttle/apps/server')
|
37
|
+
autoload :Engines, (base+'/shuttle/apps/engines')
|
38
|
+
autoload :Satellite, (base+'/shuttle/apps/satellite')
|
39
|
+
end
|
40
|
+
|
41
|
+
DEFAULT_ROOT_SYSTEM_DIR = '/var/shuttle'
|
42
|
+
DEFAULT_USER_SYSTEM_DIR = '~/.shuttle'
|
43
|
+
STOP_STATUS = 101
|
44
|
+
RESTART_STATUS = 102
|
45
|
+
RELOAD_STATUS = 103
|
46
|
+
QUICK_CERT = "http://segment7.net/projects/ruby/QuickCert/QuickCert-1.0.2.tar.gz"
|
47
|
+
|
48
|
+
Shuttle::ExceptionHandler.setup
|
49
|
+
extend ExceptionHandler
|
50
|
+
|
51
|
+
def self.client(token=nil)
|
52
|
+
unless @client
|
53
|
+
@client = Shuttle::Client.current(token)
|
54
|
+
unless @client
|
55
|
+
puts "Failed to connect to the shuttle!"
|
56
|
+
exit(1)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
@client
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.system
|
63
|
+
@system ||= Shuttle::System.shared
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.version
|
67
|
+
unless @version
|
68
|
+
if __FILE__ =~ /\/shuttle-([^\/]+)\//
|
69
|
+
@version = $1
|
70
|
+
else
|
71
|
+
@version = 'edge'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
@version
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.server?(value=nil)
|
78
|
+
@is_server = value unless value.nil?
|
79
|
+
@is_server
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__)+'/../lib/shuttle'
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simonmenke-shuttle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.07
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simon Menke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-02 00:00:00 -07:00
|
13
|
+
default_executable: shuttle
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thor
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rubigen
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.2
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: simple-daemon
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.1.2
|
44
|
+
version:
|
45
|
+
description: Manage satellites
|
46
|
+
email: simon.menke@gmail.com
|
47
|
+
executables:
|
48
|
+
- shuttle
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files: []
|
52
|
+
|
53
|
+
files:
|
54
|
+
- spec/actor/actions_spec.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
- bin/shuttle
|
57
|
+
- lib/rubygems_plugin.rb
|
58
|
+
- lib/shuttle/actor/actions.rb
|
59
|
+
- lib/shuttle/actor.rb
|
60
|
+
- lib/shuttle/actors/apache_actor.rb
|
61
|
+
- lib/shuttle/actors/base_actor.rb
|
62
|
+
- lib/shuttle/actors/mysql_actor.rb
|
63
|
+
- lib/shuttle/actors/passenger_actor.rb
|
64
|
+
- lib/shuttle/actors/plesk_actor.rb
|
65
|
+
- lib/shuttle/actors/sqlite3_actor.rb
|
66
|
+
- lib/shuttle/app_runner.rb
|
67
|
+
- lib/shuttle/apps/dev.rb
|
68
|
+
- lib/shuttle/apps/engines.rb
|
69
|
+
- lib/shuttle/apps/jobs.rb
|
70
|
+
- lib/shuttle/apps/satellite.rb
|
71
|
+
- lib/shuttle/apps/server.rb
|
72
|
+
- lib/shuttle/client/auth_token.rb
|
73
|
+
- lib/shuttle/client.rb
|
74
|
+
- lib/shuttle/exception_handler.rb
|
75
|
+
- lib/shuttle/extentions/rubygems_plugin.rb
|
76
|
+
- lib/shuttle/extentions/thor_extentions.rb
|
77
|
+
- lib/shuttle/job_queue.rb
|
78
|
+
- lib/shuttle/satellite/actions.rb
|
79
|
+
- lib/shuttle/satellite/dependency_loader.rb
|
80
|
+
- lib/shuttle/satellite/persistence.rb
|
81
|
+
- lib/shuttle/satellite.rb
|
82
|
+
- lib/shuttle/server/daemon.rb
|
83
|
+
- lib/shuttle/server/proxy.rb
|
84
|
+
- lib/shuttle/server/security.rb
|
85
|
+
- lib/shuttle/server.rb
|
86
|
+
- lib/shuttle/system/config.rb
|
87
|
+
- lib/shuttle/system/helper.rb
|
88
|
+
- lib/shuttle/system/options.rb
|
89
|
+
- lib/shuttle/system/process_user.rb
|
90
|
+
- lib/shuttle/system/satellites.rb
|
91
|
+
- lib/shuttle/system/shell.rb
|
92
|
+
- lib/shuttle/system.rb
|
93
|
+
- lib/shuttle/systems/centos_plesk_system.rb
|
94
|
+
- lib/shuttle/systems/macports_system.rb
|
95
|
+
- lib/shuttle.rb
|
96
|
+
- app_generators/engine/engine_generator.rb
|
97
|
+
- app_generators/engine/templates/config/routes.rb
|
98
|
+
- app_generators/engine/templates/init.rb
|
99
|
+
- app_generators/engine/templates/lib/engine.rb
|
100
|
+
- app_generators/engine/templates/rails/init.rb
|
101
|
+
has_rdoc: false
|
102
|
+
homepage: http://github.com/simonmenke/shuttle
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: "0"
|
119
|
+
version:
|
120
|
+
requirements: []
|
121
|
+
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.2.0
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: Manage satellites
|
127
|
+
test_files:
|
128
|
+
- spec/actor/actions_spec.rb
|
129
|
+
- spec/spec_helper.rb
|