-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.rb
executable file
·104 lines (88 loc) · 2.63 KB
/
controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env ruby
## Splay Controller ### v1.1 ###
## Copyright 2006-2011
## http://www.splay-project.org
##
##
##
## This file is part of Splay.
##
## Splayd is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 3 of the License,
## or (at your option) any later version.
##
## Splayd is distributed in the hope that it will be useful,but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Splayd. If not, see <http://www.gnu.org/licenses/>.
# This file will execute all the daemons (including multiple splayds and logds) on
# this computer. Because DBI is not fork safe (if a process halt, the connection
# is closed), we give a different DB connection to every process. We do that too
# because ruby (1.8) threads are not efficient and a splayd (daemon) will have
# dificulties to manage more than 100 threads (=> splayds).
#
# Each 'daemon' can be run standalone. Following the example in this file, you can
# see how easily you would be able to run multiple splayd/jobs on multiple
# computers.
require File.expand_path(File.join(File.dirname(__FILE__), 'lib/common'))
require File.expand_path(File.join(File.dirname(__FILE__), 'lib/all'))
# Redefine the log level (by default ERROR)
$log.level = Logger::DEBUG
puts ">>> Splayd Controller #{SplayControllerConfig::CTLVersion} <<<"
puts
puts 'http://www.splay-project.org'
puts 'Splay Controller is licensed under GPL v3, see COPYING'
puts
# Reset Distributed Locks
$db = DBUtils.get_new
$db.run("UPDATE locks SET job_reservation='0' WHERE id ='1'")
# Init used the $db
Splayd.init
$db.disconnect
(0...SplayControllerConfig::NumLogd).each do |i|
fork do
$db = DBUtils.get_new
LogdServer.new(SplayControllerConfig::LogdPort + i).run.join
end
end
(0...SplayControllerConfig::NumSplayd).each do |i|
fork do
$db = DBUtils.get_new
SplaydServer.new(SplayControllerConfig::SplaydPort + i).run.join
end
end
fork do
$db = DBUtils.get_new
JobdStandard.run.join
end
fork do
$db = DBUtils.get_new
JobdTrace.init
JobdTrace.run.join
end
fork do
$db = DBUtils.get_new
Unseend.run.join
end
fork do
$db = DBUtils.get_new
Statusd.run.join
end
fork do
$db = DBUtils.get_new
Loadavgd.run.join
end
fork do
$db = DBUtils.get_new
Blacklistd.run.join
end
fork do
$db = DBUtils.get_new
JobdTraceAlt.run.join
end
# end only on interruption
loop { sleep 1000 }