timocratic-skynet 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +152 -0
- data/License.txt +20 -0
- data/Manifest.txt +144 -0
- data/README.txt +178 -0
- data/Rakefile +5 -0
- data/app_generators/skynet_install/USAGE +5 -0
- data/app_generators/skynet_install/skynet_install_generator.rb +94 -0
- data/app_generators/skynet_install/templates/migration.rb +43 -0
- data/app_generators/skynet_install/templates/skynet_config.rb +50 -0
- data/app_generators/skynet_install/templates/skynet_initializer.rb +1 -0
- data/app_generators/skynet_install/templates/skynet_mysql_schema.sql +33 -0
- data/bin/skynet +71 -0
- data/bin/skynet_install +36 -0
- data/bin/skynet_tuplespace_server +74 -0
- data/config/hoe.rb +75 -0
- data/config/requirements.rb +17 -0
- data/examples/dgrep/README +70 -0
- data/examples/dgrep/config/skynet_config.rb +26 -0
- data/examples/dgrep/data/shakespeare/README +2 -0
- data/examples/dgrep/data/shakespeare/poetry/loverscomplaint +381 -0
- data/examples/dgrep/data/shakespeare/poetry/rapeoflucrece +2199 -0
- data/examples/dgrep/data/shakespeare/poetry/sonnets +2633 -0
- data/examples/dgrep/data/shakespeare/poetry/various +640 -0
- data/examples/dgrep/data/shakespeare/poetry/venusandadonis +1423 -0
- data/examples/dgrep/data/testfile1.txt +1 -0
- data/examples/dgrep/data/testfile2.txt +1 -0
- data/examples/dgrep/data/testfile3.txt +1 -0
- data/examples/dgrep/data/testfile4.txt +1 -0
- data/examples/dgrep/lib/dgrep.rb +59 -0
- data/examples/dgrep/lib/mapreduce_test.rb +32 -0
- data/examples/dgrep/lib/most_common_words.rb +45 -0
- data/examples/dgrep/script/dgrep +75 -0
- data/examples/rails_mysql_example/README +66 -0
- data/examples/rails_mysql_example/Rakefile +10 -0
- data/examples/rails_mysql_example/app/controllers/application.rb +10 -0
- data/examples/rails_mysql_example/app/helpers/application_helper.rb +3 -0
- data/examples/rails_mysql_example/app/models/user.rb +21 -0
- data/examples/rails_mysql_example/app/models/user_favorite.rb +5 -0
- data/examples/rails_mysql_example/app/models/user_mailer.rb +12 -0
- data/examples/rails_mysql_example/app/views/user_mailer/welcome.erb +5 -0
- data/examples/rails_mysql_example/config/boot.rb +109 -0
- data/examples/rails_mysql_example/config/database.yml +42 -0
- data/examples/rails_mysql_example/config/environment.rb +59 -0
- data/examples/rails_mysql_example/config/environments/development.rb +18 -0
- data/examples/rails_mysql_example/config/environments/production.rb +19 -0
- data/examples/rails_mysql_example/config/environments/test.rb +22 -0
- data/examples/rails_mysql_example/config/initializers/inflections.rb +10 -0
- data/examples/rails_mysql_example/config/initializers/mime_types.rb +5 -0
- data/examples/rails_mysql_example/config/initializers/skynet.rb +1 -0
- data/examples/rails_mysql_example/config/routes.rb +35 -0
- data/examples/rails_mysql_example/config/skynet_config.rb +36 -0
- data/examples/rails_mysql_example/db/migrate/001_create_skynet_tables.rb +43 -0
- data/examples/rails_mysql_example/db/migrate/002_create_users.rb +16 -0
- data/examples/rails_mysql_example/db/migrate/003_create_user_favorites.rb +14 -0
- data/examples/rails_mysql_example/db/schema.rb +85 -0
- data/examples/rails_mysql_example/db/skynet_mysql_schema.sql +33 -0
- data/examples/rails_mysql_example/doc/README_FOR_APP +2 -0
- data/examples/rails_mysql_example/lib/tasks/rails_mysql_example.rake +20 -0
- data/examples/rails_mysql_example/public/.htaccess +40 -0
- data/examples/rails_mysql_example/public/404.html +30 -0
- data/examples/rails_mysql_example/public/422.html +30 -0
- data/examples/rails_mysql_example/public/500.html +30 -0
- data/examples/rails_mysql_example/public/dispatch.cgi +10 -0
- data/examples/rails_mysql_example/public/dispatch.fcgi +24 -0
- data/examples/rails_mysql_example/public/dispatch.rb +10 -0
- data/examples/rails_mysql_example/public/favicon.ico +0 -0
- data/examples/rails_mysql_example/public/images/rails.png +0 -0
- data/examples/rails_mysql_example/public/index.html +277 -0
- data/examples/rails_mysql_example/public/javascripts/application.js +2 -0
- data/examples/rails_mysql_example/public/javascripts/controls.js +963 -0
- data/examples/rails_mysql_example/public/javascripts/dragdrop.js +972 -0
- data/examples/rails_mysql_example/public/javascripts/effects.js +1120 -0
- data/examples/rails_mysql_example/public/javascripts/prototype.js +4225 -0
- data/examples/rails_mysql_example/public/robots.txt +5 -0
- data/examples/rails_mysql_example/script/about +3 -0
- data/examples/rails_mysql_example/script/console +3 -0
- data/examples/rails_mysql_example/script/destroy +3 -0
- data/examples/rails_mysql_example/script/generate +3 -0
- data/examples/rails_mysql_example/script/performance/benchmarker +3 -0
- data/examples/rails_mysql_example/script/performance/profiler +3 -0
- data/examples/rails_mysql_example/script/performance/request +3 -0
- data/examples/rails_mysql_example/script/plugin +3 -0
- data/examples/rails_mysql_example/script/process/inspector +3 -0
- data/examples/rails_mysql_example/script/process/reaper +3 -0
- data/examples/rails_mysql_example/script/process/spawner +3 -0
- data/examples/rails_mysql_example/script/runner +3 -0
- data/examples/rails_mysql_example/script/server +3 -0
- data/examples/rails_mysql_example/test/fixtures/user_favorites.yml +9 -0
- data/examples/rails_mysql_example/test/fixtures/users.yml +11 -0
- data/examples/rails_mysql_example/test/test_helper.rb +38 -0
- data/examples/rails_mysql_example/test/unit/user_favorite_test.rb +8 -0
- data/examples/rails_mysql_example/test/unit/user_test.rb +8 -0
- data/extras/README +7 -0
- data/extras/init.d/skynet +87 -0
- data/extras/nagios/check_skynet.sh +121 -0
- data/extras/rails/controllers/skynet_controller.rb +43 -0
- data/extras/rails/views/skynet/index.rhtml +137 -0
- data/lib/skynet.rb +95 -0
- data/lib/skynet/mapreduce_helper.rb +74 -0
- data/lib/skynet/mapreduce_test.rb +56 -0
- data/lib/skynet/message_queue_adapters/message_queue_adapter.rb +70 -0
- data/lib/skynet/message_queue_adapters/mysql.rb +509 -0
- data/lib/skynet/message_queue_adapters/tuple_space.rb +316 -0
- data/lib/skynet/skynet_active_record_extensions.rb +280 -0
- data/lib/skynet/skynet_config.rb +232 -0
- data/lib/skynet/skynet_console.rb +50 -0
- data/lib/skynet/skynet_console_helper.rb +66 -0
- data/lib/skynet/skynet_debugger.rb +138 -0
- data/lib/skynet/skynet_guid_generator.rb +68 -0
- data/lib/skynet/skynet_job.rb +892 -0
- data/lib/skynet/skynet_launcher.rb +40 -0
- data/lib/skynet/skynet_logger.rb +62 -0
- data/lib/skynet/skynet_manager.rb +706 -0
- data/lib/skynet/skynet_message.rb +359 -0
- data/lib/skynet/skynet_message_queue.rb +136 -0
- data/lib/skynet/skynet_partitioners.rb +96 -0
- data/lib/skynet/skynet_ruby_extensions.rb +53 -0
- data/lib/skynet/skynet_task.rb +118 -0
- data/lib/skynet/skynet_tuplespace_server.rb +83 -0
- data/lib/skynet/skynet_worker.rb +451 -0
- data/lib/skynet/version.rb +9 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_active_record_extensions.rb +138 -0
- data/test/test_generator_helper.rb +20 -0
- data/test/test_helper.rb +10 -0
- data/test/test_mysql_message_queue_adapter.rb +263 -0
- data/test/test_skynet.rb +19 -0
- data/test/test_skynet_install_generator.rb +49 -0
- data/test/test_skynet_job.rb +717 -0
- data/test/test_skynet_manager.rb +157 -0
- data/test/test_skynet_message.rb +229 -0
- data/test/test_skynet_task.rb +24 -0
- data/test/test_tuplespace_message_queue.rb +174 -0
- data/website/index.html +181 -0
- data/website/index.txt +98 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +247 -0
data/Rakefile
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
class SkynetInstallGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
4
|
+
Config::CONFIG['ruby_install_name'])
|
5
|
+
|
6
|
+
default_options :in_rails => false
|
7
|
+
default_options :mysql => false
|
8
|
+
|
9
|
+
attr_reader :name
|
10
|
+
attr_reader :in_rails
|
11
|
+
attr_reader :mysql
|
12
|
+
|
13
|
+
def initialize(runtime_args, runtime_options = {})
|
14
|
+
super
|
15
|
+
usage if args.empty?
|
16
|
+
@destination_root = File.expand_path(args.shift)
|
17
|
+
@name = base_name
|
18
|
+
extract_options
|
19
|
+
end
|
20
|
+
|
21
|
+
def manifest
|
22
|
+
record do |m|
|
23
|
+
|
24
|
+
# Ensure appropriate folder(s) exists
|
25
|
+
BASEDIRS.each { |path| m.directory path }
|
26
|
+
|
27
|
+
# Create stubs
|
28
|
+
m.template "skynet_config.rb", "config/skynet_config.rb", :collision => :ask, :chmod => 0655
|
29
|
+
if @in_rails
|
30
|
+
m.directory 'config/initializers'
|
31
|
+
m.template "skynet_initializer.rb", "config/initializers/skynet.rb", :collision => :ask, :chmod => 0655
|
32
|
+
end
|
33
|
+
if @mysql
|
34
|
+
m.directory 'db/migrate'
|
35
|
+
m.template "skynet_mysql_schema.sql", "db/skynet_mysql_schema.sql", :collision => :ask, :chmod => 0655
|
36
|
+
m.migration_template "migration.rb", "db/migrate",
|
37
|
+
:collision => :ask,
|
38
|
+
:assigns => {
|
39
|
+
:migration_name => "CreateSkynetTables"
|
40
|
+
}, :migration_file_name => "create_skynet_tables"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
def banner
|
47
|
+
<<-EOS
|
48
|
+
Creates a ...
|
49
|
+
|
50
|
+
USAGE: #{spec.name} [--rails] [--mysql] directory (can be '.' for current)"
|
51
|
+
Installs:
|
52
|
+
./config/skynet_config.rb
|
53
|
+
EOS
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_options!(opts)
|
57
|
+
opts.separator ''
|
58
|
+
opts.separator 'Options:'
|
59
|
+
# For each option below, place the default
|
60
|
+
# at the top of the file next to "default_options"
|
61
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
62
|
+
opts.on("--mysql",
|
63
|
+
"Include mysql migration if you want to use mysql as your message queue.
|
64
|
+
Installs:
|
65
|
+
./db/skynet_mysql_schema.sql
|
66
|
+
./db/migrate/db/migrate/###_create_skynet_tables.rb
|
67
|
+
") do |mysql|
|
68
|
+
options[:mysql] = true if mysql
|
69
|
+
end
|
70
|
+
opts.on("-r", "--rails",
|
71
|
+
"Install into rails app.
|
72
|
+
Installs:
|
73
|
+
./config/initializers/skynet.rb
|
74
|
+
(If using rails 1, make sure to add require 'skynet' to your environment.rb)",
|
75
|
+
"Default: false") do |rails|
|
76
|
+
options[:rails] = true if rails
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def extract_options
|
81
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
82
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
83
|
+
# raw instance variable value.
|
84
|
+
@in_rails = options[:rails]
|
85
|
+
@mysql = options[:mysql]
|
86
|
+
end
|
87
|
+
|
88
|
+
# Installation skeleton. Intermediate directories are automatically
|
89
|
+
# created so don't sweat their absence here.
|
90
|
+
BASEDIRS = %w(
|
91
|
+
config
|
92
|
+
log
|
93
|
+
)
|
94
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :skynet_message_queues do |t|
|
4
|
+
t.column :id, "bigint unsigned primary key"
|
5
|
+
t.column :queue_id, :integer, :default => 0
|
6
|
+
t.column :tran_id, "bigint unsigned"
|
7
|
+
t.column :created_on, :timestamp
|
8
|
+
t.column :updated_on, :timestamp
|
9
|
+
t.column :tasktype, :string
|
10
|
+
t.column :task_id, 'bigint unsigned'
|
11
|
+
t.column :job_id, 'bigint unsigned'
|
12
|
+
t.column :raw_payload, "longtext"
|
13
|
+
t.column :payload_type, :string
|
14
|
+
t.column :name, :string
|
15
|
+
t.column :expiry, :integer
|
16
|
+
t.column :expire_time, "decimal(16,4)"
|
17
|
+
t.column :iteration, :integer
|
18
|
+
t.column :version, :integer
|
19
|
+
t.column :timeout, "decimal(16,4)"
|
20
|
+
t.column :retry, :integer, :default => 0
|
21
|
+
end
|
22
|
+
create_table :skynet_queue_temperature do |t|
|
23
|
+
t.column :id, "bigint unsigned primary key"
|
24
|
+
t.column :queue_id, :integer, :default => 0
|
25
|
+
t.column :updated_on, :timestamp
|
26
|
+
t.column :count, :integer, :default => 0
|
27
|
+
t.column :temperature, "decimal(6,4) default 1"
|
28
|
+
t.column :type, :string
|
29
|
+
end
|
30
|
+
add_index :skynet_message_queues, :job_id
|
31
|
+
add_index :skynet_message_queues, :task_id
|
32
|
+
add_index :skynet_message_queues, :tran_id, :unique => true
|
33
|
+
add_index :skynet_message_queues, [:queue_id,:tasktype,:payload_type,:expire_time], :name => "index_skynet_mqueue_for_take"
|
34
|
+
execute "insert into skynet_queue_temperature (queue_id,type) values (0,'master')"
|
35
|
+
execute "insert into skynet_queue_temperature (queue_id,type) values (0,'any')"
|
36
|
+
execute "insert into skynet_queue_temperature (queue_id,type) values (0,'task')"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.down
|
40
|
+
drop_table :skynet_queue_temperature
|
41
|
+
drop_table :skynet_message_queues
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Skynet Configuration File. Should be in APP_ROOT/config/skynet_config.rb
|
2
|
+
# Start skynet from within your app root with
|
3
|
+
# > skynet start
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'skynet'
|
7
|
+
|
8
|
+
<% if in_rails -%>
|
9
|
+
# Load your rails app
|
10
|
+
if not defined?(RAILS_GEM_VERSION)
|
11
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../config/environment'
|
12
|
+
end
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
Skynet::CONFIG[:SKYNET_LOG_LEVEL] = Logger::ERROR
|
16
|
+
<% if in_rails -%>
|
17
|
+
Skynet::CONFIG[:APP_ROOT] = RAILS_ROOT
|
18
|
+
Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT]+ "/log")
|
19
|
+
Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT] + "/log")
|
20
|
+
Skynet::CONFIG[:SKYNET_LOG_FILE] = "skynet_#{RAILS_ENV}.log"
|
21
|
+
Skynet::CONFIG[:SKYNET_PID_FILE] = "skynet_#{RAILS_ENV}.pid"
|
22
|
+
<% else -%>
|
23
|
+
Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
|
24
|
+
Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(File.dirname(__FILE__) + "/../log")
|
25
|
+
<% end -%>
|
26
|
+
|
27
|
+
<% if mysql -%>
|
28
|
+
<% if not in_rails -%>
|
29
|
+
# Use the mysql message queue adapter
|
30
|
+
Skynet::CONFIG[:MESSAGE_QUEUE_ADAPTER] = "Skynet::MessageQueueAdapter::Mysql"
|
31
|
+
Skynet::CONFIG[:MYSQL_HOST] = "localhost"
|
32
|
+
Skynet::CONFIG[:MYSQL_USERNAME] = "root"
|
33
|
+
Skynet::CONFIG[:MYSQL_PASSWORD] = ""
|
34
|
+
Skynet::CONFIG[:MYSQL_DATABASE] = "skynet"
|
35
|
+
<% else %>
|
36
|
+
# Use the mysql message queue adapter
|
37
|
+
Skynet::CONFIG[:MESSAGE_QUEUE_ADAPTER] = "Skynet::MessageQueueAdapter::Mysql"
|
38
|
+
<% end -%>
|
39
|
+
<% end -%>
|
40
|
+
|
41
|
+
# ==================================================================
|
42
|
+
# = Require any other libraries you want skynet to know about here =
|
43
|
+
# ==================================================================
|
44
|
+
|
45
|
+
|
46
|
+
# ===========================================
|
47
|
+
# = Set your own configuration options here =
|
48
|
+
# ===========================================
|
49
|
+
# You can also configure skynet with
|
50
|
+
# Skynet.configure(:SOME_CONFIG_OPTION => true, :SOME_OTHER_CONFIG => 3)
|
@@ -0,0 +1 @@
|
|
1
|
+
require RAILS_ROOT+'/config/skynet_config.rb'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
CREATE TABLE skynet_message_queues (
|
2
|
+
id int(11) NOT NULL auto_increment,
|
3
|
+
queue_id int(11) default '0',
|
4
|
+
tran_id bigint(20) unsigned default NULL,
|
5
|
+
created_on datetime default NULL,
|
6
|
+
updated_on datetime default NULL,
|
7
|
+
tasktype varchar(255) default NULL,
|
8
|
+
task_id bigint(20) unsigned default NULL,
|
9
|
+
job_id bigint(20) unsigned default NULL,
|
10
|
+
raw_payload longtext,
|
11
|
+
payload_type varchar(255) default NULL,
|
12
|
+
name varchar(255) default NULL,
|
13
|
+
expiry int(11) default NULL,
|
14
|
+
expire_time decimal(16,4) default NULL,
|
15
|
+
iteration int(11) default NULL,
|
16
|
+
version int(11) default NULL,
|
17
|
+
timeout decimal(16,4) default NULL,
|
18
|
+
retry int(11) default '0',
|
19
|
+
PRIMARY KEY (id),
|
20
|
+
UNIQUE KEY index_skynet_message_queues_on_tran_id (tran_id),
|
21
|
+
KEY index_skynet_message_queues_on_job_id (job_id),
|
22
|
+
KEY index_skynet_message_queues_on_task_id (task_id),
|
23
|
+
KEY index_skynet_mqueue_for_take (queue_id,tasktype,payload_type,expire_time)
|
24
|
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
25
|
+
CREATE TABLE skynet_queue_temperature (
|
26
|
+
id int(11) NOT NULL auto_increment,
|
27
|
+
queue_id int(11) default '0',
|
28
|
+
updated_on datetime default NULL,
|
29
|
+
count int(11) default '0',
|
30
|
+
temperature decimal(6,4) default NULL,
|
31
|
+
type varchar(255) default NULL,
|
32
|
+
PRIMARY KEY (id)
|
33
|
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
data/bin/skynet
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This is the main skynet starter script.
|
4
|
+
# It can be used to start the skynet_tuplespace_server as well as all skynet workers.
|
5
|
+
# It is important that this script has access to your code. If you want to run
|
6
|
+
# skynet within your code you'll want to read about bin/skynet_install[link:files/bin/skynet_install.html]
|
7
|
+
#
|
8
|
+
# Usage: skynet [options]
|
9
|
+
# -w, --workers WORKERS Number of workers to start. The default is 4 and is stored in Skynet::CONFIG[:NUMBER_OF_WORKERS]
|
10
|
+
# -i, --increment-worker-version Increment Worker Version
|
11
|
+
# -a, --add-workers WORKERS Number of workers to add.
|
12
|
+
# -k, --remove-workers WORKERS Number of workers to remove.
|
13
|
+
# -r, --required LIBRARY Require the specified libraries
|
14
|
+
# --restart-all-workers Restart All Workers
|
15
|
+
# --restart-workers Restart Workers
|
16
|
+
#
|
17
|
+
# If you have chosen to use the TupleSpace message queue adapter this script will see if there is an available TS first
|
18
|
+
# and start one if there is not. You can also start the bin/skynet_tuplespace_server[link:files/bin/skynet_tuplespace_server.html] manually.
|
19
|
+
#
|
20
|
+
# Running skynet starts a Skynet::Manager which in turn spawns the Skynet::Worker processes with the appropriate options.
|
21
|
+
# You only need to run skynet once per machine. If you want to add more workers, use the appropriate flags above to do so.
|
22
|
+
# Only one manager should be running per machine. The Skynet::Manager does not dole out tasks
|
23
|
+
#
|
24
|
+
# You should set all of your Skynet::CONFIG (or Skynet.configure()) options here (or in one of your environment files.)
|
25
|
+
# See Skynet::Config for more information on configuration options.
|
26
|
+
|
27
|
+
require 'rubygems'
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../lib/skynet.rb'
|
29
|
+
|
30
|
+
|
31
|
+
if config_arg = ARGV.detect {|i| i =~ /--help/ }
|
32
|
+
Skynet.start
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
conf_file = nil
|
37
|
+
if config_arg = ARGV.detect {|i| i =~ /--config/i }
|
38
|
+
conf_file = config_arg.split('=').last
|
39
|
+
ARGV.delete_if {|i| i =~ /--config/ }
|
40
|
+
else
|
41
|
+
['config/skynet_config.rb', 'skynet_config.rb', "../config/skynet_config.rb" , "#{ENV['HOME']}/.skynet/config.rb"].each do |path|
|
42
|
+
if File.exists?(path)
|
43
|
+
conf_file = path
|
44
|
+
break
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if conf_file
|
50
|
+
Skynet::CONFIG[:CONFIG_FILE] = File.expand_path(conf_file)
|
51
|
+
Skynet::CONFIG[:APP_ROOT] = File.dirname(Skynet::CONFIG[:CONFIG_FILE])
|
52
|
+
Skynet::CONFIG[:SKYNET_LOG_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT]+ "/../log")
|
53
|
+
Skynet::CONFIG[:SKYNET_PID_DIR] = File.expand_path(Skynet::CONFIG[:APP_ROOT] + "/../log")
|
54
|
+
begin
|
55
|
+
require conf_file
|
56
|
+
rescue MissingSourceFile => e
|
57
|
+
puts "Specified config file #{conf_file} is missing."
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
puts "using config file: #{File.expand_path(conf_file)}" unless conf_file == 'config/skynet_config.rb'
|
61
|
+
else
|
62
|
+
puts "No configuration file found.\nTry running skynet_install to create a config/skynet_config.rb or starting skynet with --config=CONFIG_FILE_LOCATION. Exiting."
|
63
|
+
exit
|
64
|
+
end
|
65
|
+
|
66
|
+
Skynet::CONFIG[:WORKER_CHECK_DELAY] ||= 4
|
67
|
+
Skynet::CONFIG[:LAUNCHER_PATH] = File.expand_path(__FILE__)
|
68
|
+
|
69
|
+
Skynet::CONFIG[:SYSTEM_RUNNER] = true
|
70
|
+
|
71
|
+
Skynet.start
|
data/bin/skynet_install
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# skynet_install is used to install skynet libraries into your application.
|
4
|
+
# Specifically, it installs a config/skynet_config.rb file
|
5
|
+
# Once you have a config/skynet_config.rb you can run skynet start from within your root_app_dir/
|
6
|
+
# This is also how you can run skynet from within rails. (using --rails)
|
7
|
+
#
|
8
|
+
# USAGE: skynet_install [--rails] directory/ (can be '.' for current)"
|
9
|
+
#
|
10
|
+
# Options:
|
11
|
+
# -v, --version Show the skynet_install version number and quit.
|
12
|
+
# --mysql Include mysql migration if you want to use mysql as your message queue
|
13
|
+
# -r, --rails Install into rails app
|
14
|
+
# Default: false
|
15
|
+
# General Options:
|
16
|
+
# -h, --help Show this help message and quit.
|
17
|
+
# -p, --pretend Run but do not make any changes.
|
18
|
+
# -f, --force Overwrite files that already exist.
|
19
|
+
# -s, --skip Skip files that already exist.
|
20
|
+
# -q, --quiet Suppress normal output.
|
21
|
+
# -t, --backtrace Debugging: show backtrace on errors.
|
22
|
+
# -c, --svn Modify files with subversion. (Note: svn must be in path)
|
23
|
+
#
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
require 'rubigen'
|
27
|
+
|
28
|
+
if %w(-v --version).include? ARGV.first
|
29
|
+
require 'skynet_install/version'
|
30
|
+
puts "#{File.basename($0)} #{SkynetInstall::VERSION::STRING}"
|
31
|
+
exit(0)
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'rubigen/scripts/generate'
|
35
|
+
RubiGen::Base.use_application_sources! :skynet_install
|
36
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'skynet_install')
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# SkynetTupleSpace server is one of the message queues you can use with Skynet. Make sure you set:
|
4
|
+
# Skynet::CONFIG[:MESSAGE_QUEUE_ADAPTER] = "Skynet::MessageQueueAdapter::TupleSpace"
|
5
|
+
#
|
6
|
+
# Usage: skynet_tuplespace_server (start|stop|run) [options]
|
7
|
+
# -t, --ontop=TRUE Dont Daemonize
|
8
|
+
# -p, --port=PORT Port to listen on. default 7647
|
9
|
+
# -o, --logfile=LOGFILE Logfile to log to
|
10
|
+
# -l, --loglevel=LOGLEVEL Log level defaults to DEBUG
|
11
|
+
# -d, --piddir=PIDDIR Directory to put pidfile
|
12
|
+
# -u, --drburi=druby://DRB_URI What DRbURI to use
|
13
|
+
|
14
|
+
require 'rubygems'
|
15
|
+
require 'daemons'
|
16
|
+
require 'pp'
|
17
|
+
|
18
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../lib/skynet.rb'
|
19
|
+
|
20
|
+
options = {
|
21
|
+
:port => 7647,
|
22
|
+
:logfile => Skynet::Config.pidfile_location,
|
23
|
+
:loglevel => "ERROR",
|
24
|
+
:piddir => Skynet::CONFIG[:SKYNET_PID_DIR],
|
25
|
+
:use_ringserver => Skynet::CONFIG[:TS_USE_RINGSERVER],
|
26
|
+
}
|
27
|
+
|
28
|
+
OptionParser.new do |opt|
|
29
|
+
opt.banner = "Usage: skynet_tuplespace_server (start|stop|run) [options]"
|
30
|
+
opt.on('-t', '--ontop TRUE', 'Dont Daemonize') do |v|
|
31
|
+
options[:ontop] = true if v.upcase == "TRUE" or v == "1"
|
32
|
+
end
|
33
|
+
opt.on('-p', '--port=PORT', 'Port to listen on. default 7647') do |v|
|
34
|
+
options[:port] = v.to_i
|
35
|
+
end
|
36
|
+
opt.on('-o', '--logfile=LOGFILE', 'Logfile to log to') do |v|
|
37
|
+
options[:logfile] = File.expand_path(v)
|
38
|
+
end
|
39
|
+
opt.on('-l', '--loglevel=LOGLEVEL', 'Log level defaults to DEBUG') do |v|
|
40
|
+
options[:loglevel] = v
|
41
|
+
end
|
42
|
+
opt.on('-d', '--piddir=PIDDIR', 'Directory to put pidfile') do |v|
|
43
|
+
options[:piddir] = File.expand_path(v)
|
44
|
+
end
|
45
|
+
opt.on('--use_ringserver=TRUE', 'Use ringserver?') do |v|
|
46
|
+
if v.downcase == "true" or v == "1"
|
47
|
+
options[:use_ringserver] = true
|
48
|
+
else
|
49
|
+
options[:use_ringserver] = false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
opt.on('-u', '--drburi=druby://DRB_URI', 'What DRbURI to use') do |v|
|
53
|
+
if v =~ %r{druby://}
|
54
|
+
options[:drburi] = v
|
55
|
+
else
|
56
|
+
options[:drburi] = "druby://#{v}"
|
57
|
+
end
|
58
|
+
options[:drburi] =~ /druby:\/\/.+?:(\d*)/
|
59
|
+
options[:port] ||= $1.to_i
|
60
|
+
end
|
61
|
+
|
62
|
+
opt.parse!(ARGV)
|
63
|
+
end
|
64
|
+
|
65
|
+
Daemons.run_proc("skynet_tuplespace_server#{options[:port]}",
|
66
|
+
{
|
67
|
+
:dir_mode => :normal,
|
68
|
+
:dir => options[:piddir],
|
69
|
+
:backtrace => true,
|
70
|
+
# :monitor => true,
|
71
|
+
:ontop => options[:ontop] || false
|
72
|
+
}) do
|
73
|
+
server = Skynet::TuplespaceServer.start(options)
|
74
|
+
end
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'skynet/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Adam Pisoni' # can also be an array of Authors
|
4
|
+
EMAIL = "apisoni@geni.com"
|
5
|
+
DESCRIPTION = "Skynet - A Ruby Map/Reduce Framework"
|
6
|
+
GEM_NAME = 'skynet' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'skynet' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
+
@config = nil
|
13
|
+
RUBYFORGE_USERNAME = "unknown"
|
14
|
+
def rubyforge_username
|
15
|
+
unless @config
|
16
|
+
begin
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
18
|
+
rescue
|
19
|
+
puts <<-EOS
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
23
|
+
EOS
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
REV = nil
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
33
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
34
|
+
VERS = Skynet::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', 'skynet documentation',
|
36
|
+
"--opname", "index.html",
|
37
|
+
"--line-numbers",
|
38
|
+
"--main", "README",
|
39
|
+
"--inline-source"]
|
40
|
+
|
41
|
+
class Hoe
|
42
|
+
def extra_deps
|
43
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
|
+
@extra_deps
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generate all the Rake tasks
|
49
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
|
+
p.author = AUTHOR
|
52
|
+
p.description = DESCRIPTION
|
53
|
+
p.email = EMAIL
|
54
|
+
p.summary = DESCRIPTION
|
55
|
+
p.url = HOMEPATH
|
56
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
57
|
+
p.test_globs = ["test/**/test_*.rb"]
|
58
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
59
|
+
|
60
|
+
# == Optional
|
61
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
62
|
+
p.extra_deps = [
|
63
|
+
['daemons',">= 1"],
|
64
|
+
['rubigen', ">=1.1.1"]
|
65
|
+
]
|
66
|
+
# An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
67
|
+
|
68
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
73
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
74
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
75
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|