$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
module ShinagawaSeaside
- VERSION = '0.0.2'
+ VERSION = '0.0.3'
def ShinagawaSeaside::set_tasks(ttdb, opts)
+ tasks = {
+ :start => 'ttstart',
+ :stop => 'ttstop',
+ :restart => 'ttrestart'
+ }
+ tasks[:start] = opts[:start].to_s if opts[:start]
+ tasks[:stop] = opts[:stop].to_s if opts[:stop]
+ tasks[:restart] = opts[:restart].to_s if opts[:restart]
+
ttdb = ttdb.map{|db|
h = Hash.new
db.keys.each{|k|
}
desc 'start TokyoTyrant server'
- task 'ttstart' do
+ task tasks[:start] do
puts 'starting TokyoTyrant servers..'
for tt in ttdb do
Dir.mkdir(tt[:basedir]) if !File.exists?(tt[:basedir])
end
desc 'stop TokyoTyrant server'
- task 'ttstop' do
+ task tasks[:stop] do
puts 'stopping TokyoTyrant servers..'
for tt in ttdb do
if File.exists?(tt[:pidfile])
end
desc 'restart TokyoTyrant server'
- task 'ttrestart' => ['ttstop', 'ttstart']
+ task tasks[:restart] => [tasks[:stop], tasks[:start]]
end
--- /dev/null
+require 'rubygems'
+#require 'shinagawaseaside'
+require '../../lib/shinagawaseaside'
+
+ttdb = [ { :name => 'users', :port => 20020},
+ { :name => 'videos',:port => 20021},
+ { :name => 'comments', :port => 20022} ]
+
+ShinagawaSeaside::set_tasks(ttdb,
+ :basedir => File.dirname(__FILE__)+'/ttdb',
+ :start => 'start', # set task name
+ :stop => 'stop',
+ :restart => 'restart'
+ )
require 'rubygems'
-require 'shinagawaseaside'
-#require '../../lib/shinagawaseaside'
+#require 'shinagawaseaside'
+require '../../lib/shinagawaseaside'
ttdb = [ { :name => 'users', :port => 20010},
{ :name => 'videos',:port => 20011},
require 'rubygems'
require 'yaml'
#require 'shinagawaseaside'
-require '../..//lib/shinagawaseaside'
+require '../../lib/shinagawaseaside'
begin
conf = YAML::load open(File.dirname(__FILE__)+'/config.yaml')