rest-ftp-daemon 0.95.2 → 0.100
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.
- checksums.yaml +4 -4
- data/lib/rest-ftp-daemon.rb +1 -1
- data/lib/rest-ftp-daemon/api/dashboard.rb +8 -4
- data/lib/rest-ftp-daemon/api/jobs.rb +2 -1
- data/lib/rest-ftp-daemon/api/root.rb +9 -9
- data/lib/rest-ftp-daemon/constants.rb +4 -2
- data/lib/rest-ftp-daemon/helpers.rb +6 -2
- data/lib/rest-ftp-daemon/job.rb +35 -18
- data/lib/rest-ftp-daemon/job_queue.rb +13 -11
- data/lib/rest-ftp-daemon/logger.rb +6 -27
- data/lib/rest-ftp-daemon/logger_pool.rb +37 -0
- data/lib/rest-ftp-daemon/notification.rb +10 -4
- data/lib/rest-ftp-daemon/static/css/main.css +22 -17
- data/lib/rest-ftp-daemon/views/dashboard.haml +2 -3
- data/lib/rest-ftp-daemon/views/dashboard_jobs.haml +1 -2
- data/lib/rest-ftp-daemon/worker_pool.rb +8 -15
- data/rest-ftp-daemon.yml.sample +5 -3
- metadata +3 -3
- data/lib/rest-ftp-daemon/common.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cd7cf3fc402f4257b9c878b5227467f3f250c95
|
4
|
+
data.tar.gz: 441d0c886af8f6ba67347a82318efb40521862ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e774def2fa7622368cca0d28915aaf6c45a121c438d6a4da34c408e733fc79c5611a0c72b1355c1200d5c49ec00d52b8a70198f243442d607e65f8b85ebbd7f7
|
7
|
+
data.tar.gz: 6696902d94a1130e840955a84c4cde5fac53b0df16bdebeb581c27ff7730efc12b22bf984a580be37448ea35e8aded345798ddc918fe1b89e7f90af7c0615902
|
data/lib/rest-ftp-daemon.rb
CHANGED
@@ -14,12 +14,12 @@ require "sys/cpu"
|
|
14
14
|
require 'rest-ftp-daemon/constants'
|
15
15
|
require 'rest-ftp-daemon/config'
|
16
16
|
require 'rest-ftp-daemon/exceptions'
|
17
|
-
require 'rest-ftp-daemon/common'
|
18
17
|
require 'rest-ftp-daemon/helpers'
|
19
18
|
require 'rest-ftp-daemon/uri'
|
20
19
|
require 'rest-ftp-daemon/job_queue'
|
21
20
|
require 'rest-ftp-daemon/worker_pool'
|
22
21
|
require 'rest-ftp-daemon/logger'
|
22
|
+
require 'rest-ftp-daemon/logger_pool'
|
23
23
|
require 'rest-ftp-daemon/job'
|
24
24
|
require 'rest-ftp-daemon/notification'
|
25
25
|
require 'rest-ftp-daemon/api/root'
|
@@ -32,14 +32,18 @@ module RestFtpDaemon
|
|
32
32
|
@only = params["only"].to_sym
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
case @only
|
36
|
+
when nil
|
37
|
+
@jobs_current = popped_jobs
|
38
|
+
when :queued
|
39
|
+
@jobs_current = @jobs_queued
|
37
40
|
else
|
38
|
-
@
|
41
|
+
@jobs_current = $queue.popped_reverse_sorted_by_status @only
|
39
42
|
end
|
40
43
|
|
41
|
-
# Count jobs for each status
|
44
|
+
# Count jobs for each status and total
|
42
45
|
@counts = $queue.counts_by_status
|
46
|
+
@count_all = $queue.all_size
|
43
47
|
|
44
48
|
# Get workers status
|
45
49
|
@gworker_statuses = $pool.get_worker_statuses
|
@@ -5,7 +5,8 @@ module RestFtpDaemon
|
|
5
5
|
|
6
6
|
####### CLASS CONFIG
|
7
7
|
|
8
|
-
logger RestFtpDaemon::Logger.new(:api, "API")
|
8
|
+
# logger RestFtpDaemon::Logger.new(:api, "API")
|
9
|
+
logger RestFtpDaemon::LoggerPool.instance.get :api
|
9
10
|
|
10
11
|
do_not_route_head!
|
11
12
|
do_not_route_options!
|
@@ -16,26 +17,25 @@ module RestFtpDaemon
|
|
16
17
|
format :json
|
17
18
|
|
18
19
|
|
19
|
-
#######
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
####### INITIALIZATION
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
super
|
24
|
+
end
|
24
25
|
|
25
26
|
|
26
27
|
####### HELPERS
|
27
28
|
|
28
29
|
helpers do
|
29
30
|
|
30
|
-
def info message
|
31
|
-
Root.logger.
|
31
|
+
def info message
|
32
|
+
Root.logger.info_with_id message
|
32
33
|
end
|
33
34
|
|
34
35
|
def api_error exception
|
35
36
|
{
|
36
37
|
:error => exception.message,
|
37
38
|
:message => exception.backtrace.first,
|
38
|
-
#:backtrace => exception.backtrace,
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Terrific constants
|
2
2
|
APP_NAME = "rest-ftp-daemon"
|
3
3
|
APP_CONF = "/etc/#{APP_NAME}.yml"
|
4
|
-
APP_VER = "0.
|
4
|
+
APP_VER = "0.100"
|
5
5
|
|
6
6
|
# Some global constants
|
7
7
|
IDENT_JOB_LEN = 4
|
@@ -12,7 +12,9 @@ IDENT_RANDOM_LEN = 8
|
|
12
12
|
DEFAULT_CONNECT_TIMEOUT_SEC = 30
|
13
13
|
DEFAULT_UPDATE_EVERY_KB = 2048
|
14
14
|
DEFAULT_WORKERS = 1
|
15
|
-
|
15
|
+
|
16
|
+
DEFAULT_LOGS_PIPE_WIDTH = 15
|
17
|
+
DEFAULT_LOGS_ID_WIDTH = 8
|
16
18
|
|
17
19
|
# Initialize markers
|
18
20
|
APP_STARTED = Time.now
|
@@ -28,14 +28,18 @@ module RestFtpDaemon
|
|
28
28
|
rand(36**len).to_s(36)
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.tokenize
|
31
|
+
def self.tokenize item
|
32
32
|
"[#{item}]"
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.highlight_tokens
|
35
|
+
def self.highlight_tokens path
|
36
36
|
path.gsub(/(\[[^\[]+\])/, '<span class="token">\1</span>')
|
37
37
|
end
|
38
38
|
|
39
|
+
# def self.hide_password url
|
40
|
+
# path.gsub(/(\[[^\[]+\])/, '<span class="token">\1</span>')
|
41
|
+
# end
|
42
|
+
|
39
43
|
def self.extract_filename path
|
40
44
|
# match everything that's after a slash at the end of the string
|
41
45
|
m = path.match /\/?([^\/]+)$/
|
data/lib/rest-ftp-daemon/job.rb
CHANGED
@@ -4,7 +4,7 @@ require 'double_bag_ftps'
|
|
4
4
|
require 'timeout'
|
5
5
|
|
6
6
|
module RestFtpDaemon
|
7
|
-
class Job
|
7
|
+
class Job
|
8
8
|
|
9
9
|
FIELDS = [:source, :target, :priority, :notify, :overwrite, :mkdir]
|
10
10
|
|
@@ -26,7 +26,6 @@ module RestFtpDaemon
|
|
26
26
|
def initialize job_id, params={}
|
27
27
|
# Call super
|
28
28
|
# super()
|
29
|
-
info "Job.initialize"
|
30
29
|
|
31
30
|
# Init context
|
32
31
|
@id = job_id.to_s
|
@@ -36,25 +35,27 @@ module RestFtpDaemon
|
|
36
35
|
end
|
37
36
|
@params = {}
|
38
37
|
|
38
|
+
# Logger
|
39
|
+
# @logger = RestFtpDaemon::Logger.new(:workers, "JOB #{id}")
|
40
|
+
@logger = RestFtpDaemon::LoggerPool.instance.get :workers
|
41
|
+
|
39
42
|
# Protect with a mutex
|
40
43
|
@mutex = Mutex.new
|
41
44
|
|
42
|
-
# Logger
|
43
|
-
@logger = RestFtpDaemon::Logger.new(:workers, "JOB #{id}")
|
44
|
-
|
45
45
|
# Flag current job
|
46
46
|
@queued_at = Time.now
|
47
47
|
@status = :created
|
48
48
|
|
49
49
|
# Send first notification
|
50
50
|
#info "Job.initialize/notify"
|
51
|
+
info "Job.initialized"
|
51
52
|
client_notify "rftpd.queued"
|
52
53
|
end
|
53
54
|
|
54
55
|
def close
|
55
56
|
# Close logger
|
56
|
-
info "Job.close"
|
57
|
-
|
57
|
+
# info "Job.close"
|
58
|
+
#@logger.close
|
58
59
|
end
|
59
60
|
|
60
61
|
def process
|
@@ -110,6 +111,9 @@ module RestFtpDaemon
|
|
110
111
|
rescue Errno::EHOSTDOWN => exception
|
111
112
|
return oops "rftpd.ended", exception, :job_host_is_down
|
112
113
|
|
114
|
+
rescue Errno::ENOTCONN => exception
|
115
|
+
return oops "rftpd.ended", exception, :job_connexion_failed
|
116
|
+
|
113
117
|
rescue Errno::ECONNREFUSED => exception
|
114
118
|
return oops "rftpd.ended", exception, :job_connexion_refused
|
115
119
|
|
@@ -294,7 +298,6 @@ module RestFtpDaemon
|
|
294
298
|
# Check source files presence and compute total size, they should be there, coming from Dir.glob()
|
295
299
|
@transfer_total = 0
|
296
300
|
source_matches.each do |filename|
|
297
|
-
# @ftp.close
|
298
301
|
raise RestFtpDaemon::JobSourceNotFound unless File.exists? filename
|
299
302
|
@transfer_total += File.size filename
|
300
303
|
end
|
@@ -312,18 +315,26 @@ module RestFtpDaemon
|
|
312
315
|
$queue.counter_add :transferred, @transfer_total
|
313
316
|
|
314
317
|
# Close FTP connexion
|
318
|
+
@ftp.close
|
315
319
|
info "Job.transfer disconnecting"
|
316
320
|
@status = :disconnecting
|
317
|
-
@ftp.close
|
318
321
|
end
|
319
322
|
|
320
323
|
private
|
321
324
|
|
325
|
+
def info message, level = 0
|
326
|
+
return if @logger.nil?
|
327
|
+
@logger.info_with_id message, level: level, id: @id
|
328
|
+
end
|
329
|
+
|
322
330
|
def oops signal_name, exception, error_name = nil, include_backtrace = false
|
323
331
|
# Log this error
|
324
332
|
error_name = exception.class if error_name.nil?
|
325
333
|
info "Job.oops si[#{signal_name}] er[#{error_name.to_s}] ex[#{exception.class}]"
|
326
334
|
|
335
|
+
# Close ftp connexion if open
|
336
|
+
@ftp.close unless @ftp.nil?
|
337
|
+
|
327
338
|
# Update job's internal status
|
328
339
|
@status = :failed
|
329
340
|
@error = error_name
|
@@ -346,8 +357,6 @@ module RestFtpDaemon
|
|
346
357
|
|
347
358
|
# Prepare notification if signal given
|
348
359
|
return unless signal_name
|
349
|
-
|
350
|
-
# Send the real notification
|
351
360
|
client_notify signal_name, error_name, notif_status
|
352
361
|
end
|
353
362
|
|
@@ -515,7 +524,7 @@ module RestFtpDaemon
|
|
515
524
|
stack << (Helpers.format_bytes @transfer_sent, "B")
|
516
525
|
stack << (Helpers.format_bytes @transfer_total, "B")
|
517
526
|
stack << (Helpers.format_bytes bitrate0, "bps")
|
518
|
-
info "Job.ftp_transfer" + stack.map{|txt| ("%#{
|
527
|
+
info "Job.ftp_transfer" + stack.map{|txt| ("%#{DEFAULT_LOGS_PIPE_WIDTH.to_i}s" % txt)}.join("\t")
|
519
528
|
|
520
529
|
# Update time pointer
|
521
530
|
t0 = Time.now
|
@@ -544,12 +553,20 @@ module RestFtpDaemon
|
|
544
553
|
end
|
545
554
|
|
546
555
|
def client_notify signal, error = nil, status = {}
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
556
|
+
# Skip if no URL given
|
557
|
+
return unless @notify
|
558
|
+
|
559
|
+
# Ok, create a notification!
|
560
|
+
begin
|
561
|
+
RestFtpDaemon::Notification.new @notify, {
|
562
|
+
id: @id,
|
563
|
+
signal: signal,
|
564
|
+
error: error,
|
565
|
+
status: status,
|
566
|
+
}
|
567
|
+
rescue Exception => ex
|
568
|
+
info "Job.client_notify exception: #{ex.inspect}"
|
569
|
+
end
|
553
570
|
end
|
554
571
|
|
555
572
|
def get_bitrate total, last_timestamp
|
@@ -7,19 +7,19 @@ module RestFtpDaemon
|
|
7
7
|
attr_reader :popped
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
# # Logger
|
11
|
-
@logger = RestFtpDaemon::Logger.new(:queue, "QUEUE")
|
12
|
-
|
13
10
|
# Instance variables
|
14
11
|
@queued = []
|
15
12
|
@popped = []
|
16
|
-
|
17
13
|
@waiting = []
|
18
14
|
@queued.taint # enable tainted communication
|
19
15
|
@waiting.taint
|
20
16
|
self.taint
|
21
17
|
@mutex = Mutex.new
|
22
18
|
|
19
|
+
# # Logger
|
20
|
+
# @logger = RestFtpDaemon::Logger.new(:queue, "QUEUE")
|
21
|
+
@logger = RestFtpDaemon::LoggerPool.instance.get :queue
|
22
|
+
|
23
23
|
# Identifiers generator
|
24
24
|
@last_id = 0
|
25
25
|
#@prefix = SecureRandom.hex(IDENT_JOB_LEN)
|
@@ -110,10 +110,12 @@ module RestFtpDaemon
|
|
110
110
|
def push job
|
111
111
|
# Check that item responds to "priorty" method
|
112
112
|
raise "JobQueue.push: job should respond to priority method" unless job.respond_to? :priority
|
113
|
+
raise "JobQueue.push: job should respond to id method" unless job.respond_to? :id
|
113
114
|
|
114
115
|
@mutex.synchronize do
|
115
116
|
# Push job into the queue
|
116
117
|
@queued.push job
|
118
|
+
#info "JobQueue.push: #{job.id}"
|
117
119
|
|
118
120
|
# Tell the job it's been queued
|
119
121
|
job.set_queued if job.respond_to? :set_queued
|
@@ -132,13 +134,16 @@ module RestFtpDaemon
|
|
132
134
|
|
133
135
|
|
134
136
|
def pop(non_block=false)
|
137
|
+
# info "JobQueue.pop"
|
135
138
|
@mutex.synchronize do
|
136
139
|
while true
|
137
140
|
if @queued.empty?
|
141
|
+
# info "JobQueue.pop: empty"
|
138
142
|
raise ThreadError, "queue empty" if non_block
|
139
143
|
@waiting.push Thread.current
|
140
144
|
@mutex.sleep
|
141
145
|
else
|
146
|
+
# info "JobQueue.pop: great, I'm not empty!!"
|
142
147
|
return pick_one
|
143
148
|
end
|
144
149
|
end
|
@@ -211,10 +216,6 @@ module RestFtpDaemon
|
|
211
216
|
|
212
217
|
end
|
213
218
|
|
214
|
-
def info message, level = 0
|
215
|
-
@logger.add(Logger::INFO, "#{' '*(level+1)} #{message}", progname) unless @logger.nil?
|
216
|
-
end
|
217
|
-
|
218
219
|
def pick_one # called inside a mutex/sync
|
219
220
|
# Sort jobs by priority and get the biggest one
|
220
221
|
picked = ordered_queue.last
|
@@ -225,14 +226,15 @@ module RestFtpDaemon
|
|
225
226
|
@popped.push picked
|
226
227
|
|
227
228
|
# Return picked
|
229
|
+
#info "JobQueue.pick_one: #{picked.id}"
|
228
230
|
picked
|
229
231
|
end
|
230
232
|
|
231
|
-
|
232
233
|
private
|
233
234
|
|
234
|
-
def info message
|
235
|
-
|
235
|
+
def info message
|
236
|
+
return if @logger.nil?
|
237
|
+
@logger.info_with_id message
|
236
238
|
end
|
237
239
|
|
238
240
|
end
|
@@ -1,31 +1,10 @@
|
|
1
|
-
|
2
|
-
class Logger
|
1
|
+
class Logger
|
3
2
|
|
4
|
-
|
5
|
-
# Init
|
6
|
-
@context = context
|
7
|
-
@progname = progname
|
8
|
-
|
9
|
-
# Compute file path
|
10
|
-
logfile = Settings.logs[@context] if Settings.logs.is_a? Hash
|
11
|
-
|
12
|
-
# Instantiate a logger if it's non-null
|
13
|
-
@logger = ActiveSupport::Logger.new(logfile, 'daily') unless logfile.nil?
|
14
|
-
end
|
15
|
-
|
16
|
-
def info message, level = 0
|
17
|
-
return if @logger.nil?
|
18
|
-
|
19
|
-
stamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
20
|
-
progname = "%-#{DEFAULT_LOGS_PROGNAME_TRIM.to_i}s" % @progname
|
21
|
-
line = "#{stamp} #{progname} \t#{' '*(level+1)}#{message}"
|
22
|
-
|
23
|
-
if @logger.nil?
|
24
|
-
puts line
|
25
|
-
else
|
26
|
-
@logger.add(ActiveSupport::Logger::INFO, line)
|
27
|
-
end
|
28
|
-
end
|
3
|
+
attr_accessor :pipe
|
29
4
|
|
5
|
+
def info_with_id message, options = {}
|
6
|
+
field_id = "%#{-DEFAULT_LOGS_ID_WIDTH.to_i}s" % options[:id].to_s
|
7
|
+
add Logger::INFO, "#{field_id} \t#{' '*(options[:level].to_i+1)}#{message}"
|
30
8
|
end
|
9
|
+
|
31
10
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module RestFtpDaemon
|
5
|
+
class LoggerPool
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@loggers = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def get pipe
|
13
|
+
@loggers[pipe] ||= create(pipe)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create pipe
|
17
|
+
# Compute file path / STDERR
|
18
|
+
logfile = Settings.logs[pipe] if Settings.logs.is_a? Hash
|
19
|
+
logfile ||= STDERR
|
20
|
+
#logfile ||= STDOUT
|
21
|
+
|
22
|
+
# Create the logger and return it
|
23
|
+
logger = Logger.new(logfile, 'daily') #, 10, 1024000)
|
24
|
+
logger.progname = pipe.to_s.upcase
|
25
|
+
logger.formatter = proc do |severity, datetime, progname, message|
|
26
|
+
# stamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
27
|
+
stamp = datetime.strftime("%Y-%m-%d %H:%M:%S")
|
28
|
+
field_pipe = "%-#{DEFAULT_LOGS_PIPE_WIDTH.to_i}s" % progname
|
29
|
+
"#{stamp} #{field_pipe} #{message}\n"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Finally return this logger
|
33
|
+
logger
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
3
|
module RestFtpDaemon
|
4
|
-
class Notification
|
4
|
+
class Notification
|
5
5
|
attr_accessor :job_id
|
6
6
|
attr_accessor :signal
|
7
7
|
attr_accessor :error
|
@@ -9,14 +9,14 @@ module RestFtpDaemon
|
|
9
9
|
attr_accessor :status
|
10
10
|
attr_accessor :url
|
11
11
|
attr_accessor :job
|
12
|
-
attr_accessor :key
|
13
12
|
|
14
13
|
def initialize url, params
|
15
14
|
# Generate a random key
|
16
|
-
|
15
|
+
@id = Helpers.identifier(IDENT_NOTIF_LEN)
|
17
16
|
|
18
17
|
# Logger
|
19
|
-
@logger = RestFtpDaemon::Logger.new(:workers, "NOTIF #{key}")
|
18
|
+
# @logger = RestFtpDaemon::Logger.new(:workers, "NOTIF #{key}")
|
19
|
+
@logger = RestFtpDaemon::LoggerPool.instance.get :notify
|
20
20
|
|
21
21
|
# Check context
|
22
22
|
if url.nil?
|
@@ -59,5 +59,11 @@ module RestFtpDaemon
|
|
59
59
|
|
60
60
|
protected
|
61
61
|
|
62
|
+
def info message, level = 0
|
63
|
+
return if @logger.nil?
|
64
|
+
#puts "JOB: #{message}"
|
65
|
+
@logger.info_with_id message, level: level, id: @id
|
66
|
+
end
|
67
|
+
|
62
68
|
end
|
63
69
|
end
|
@@ -3,10 +3,11 @@
|
|
3
3
|
}
|
4
4
|
|
5
5
|
.transfer-method {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
width: 35px;
|
7
|
+
}
|
8
|
+
|
9
|
+
.worker-label {
|
10
|
+
width: 25px;
|
10
11
|
}
|
11
12
|
|
12
13
|
.nobr {
|
@@ -25,20 +26,25 @@ table tr td, .fixed {
|
|
25
26
|
/*font-weight: bold;*/
|
26
27
|
}
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
.label {
|
30
|
+
font-size: 90%;
|
31
|
+
padding: 2px 4px;
|
32
|
+
font-weight: normal;
|
33
|
+
display: inline-block;
|
34
|
+
font-family: sans-serif;
|
35
|
+
}
|
36
|
+
|
33
37
|
.label-outline {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
+
color: black;
|
39
|
+
border: 1px solid #999;
|
40
|
+
background-color: transparent;
|
41
|
+
}
|
38
42
|
|
39
|
-
.
|
40
|
-
|
41
|
-
|
43
|
+
.label-contrast {
|
44
|
+
color: white;
|
45
|
+
border: 1px dotted #999;
|
46
|
+
background-color: black;
|
47
|
+
}
|
42
48
|
|
43
49
|
h2 {
|
44
50
|
font-size: 1.5em;
|
@@ -55,4 +61,3 @@ h2 {
|
|
55
61
|
margin-bottom: 0;
|
56
62
|
}
|
57
63
|
|
58
|
-
|
@@ -33,7 +33,7 @@
|
|
33
33
|
.btn-group.btn-group-md
|
34
34
|
- klass = @only.nil? ? "btn-info" : ""
|
35
35
|
%a.btn.btn-default{href: "?only=", class: klass}
|
36
|
-
ALL (#{@
|
36
|
+
ALL (#{@count_all})
|
37
37
|
.btn-group.btn-group-md
|
38
38
|
- @counts.each do |status, count|
|
39
39
|
- klass = (status == @only) ? "btn-info" : ""
|
@@ -59,8 +59,7 @@
|
|
59
59
|
%tr
|
60
60
|
%th{colspan: 10}
|
61
61
|
|
62
|
-
= render :dashboard_jobs, {jobs: @
|
63
|
-
|
62
|
+
= render :dashboard_jobs, {jobs: @jobs_current, counts: @counts}
|
64
63
|
|
65
64
|
|
66
65
|
.row
|
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
%td
|
29
29
|
- unless job.wid.nil?
|
30
|
-
.label.label-
|
30
|
+
.label.label-default.flag.worker-label= job.wid
|
31
31
|
|
32
32
|
%td{title: job.get(:source_path)}
|
33
33
|
=# Helpers.job_method_label job.get(:source_method)
|
@@ -70,4 +70,3 @@
|
|
70
70
|
- if (bitrate = job.get :transfer_bitrate)
|
71
71
|
= Helpers.format_bytes(bitrate, "bps")
|
72
72
|
|
73
|
-
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module RestFtpDaemon
|
2
|
-
class WorkerPool
|
2
|
+
class WorkerPool
|
3
3
|
|
4
4
|
attr_reader :requested, :processed, :wid
|
5
5
|
|
6
|
-
def initialize
|
6
|
+
def initialize number_threads
|
7
7
|
# Logger
|
8
|
-
@logger = RestFtpDaemon::
|
8
|
+
@logger = RestFtpDaemon::LoggerPool.instance.get :workers
|
9
9
|
|
10
10
|
# Check parameters
|
11
11
|
raise "A thread count of #{number_threads} is less than one" if number_threads < 1
|
@@ -29,16 +29,6 @@ module RestFtpDaemon
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
-
# def wait
|
33
|
-
# item = @out.pop
|
34
|
-
# @lock.synchronize { @processed += 1 }
|
35
|
-
# block_given? ? (yield item) : item
|
36
|
-
# end
|
37
|
-
|
38
|
-
# def progname
|
39
|
-
# "WORKER #{@wid}"
|
40
|
-
# end
|
41
|
-
|
42
32
|
def work wid
|
43
33
|
worker_status wid, "starting"
|
44
34
|
loop do
|
@@ -74,8 +64,6 @@ module RestFtpDaemon
|
|
74
64
|
# Clean job status
|
75
65
|
worker_status wid, :ready
|
76
66
|
job.wid = nil
|
77
|
-
# sleep 1
|
78
|
-
|
79
67
|
end
|
80
68
|
|
81
69
|
end
|
@@ -89,6 +77,11 @@ module RestFtpDaemon
|
|
89
77
|
|
90
78
|
protected
|
91
79
|
|
80
|
+
def info message
|
81
|
+
return if @logger.nil?
|
82
|
+
@logger.info_with_id message
|
83
|
+
end
|
84
|
+
|
92
85
|
def worker_status wid, status, jobid = nil
|
93
86
|
@mutex.synchronize do
|
94
87
|
@statuses[wid] ||= {}
|
data/rest-ftp-daemon.yml.sample
CHANGED
@@ -17,9 +17,11 @@ defaults: &defaults
|
|
17
17
|
#clean_finished: 600
|
18
18
|
|
19
19
|
logs:
|
20
|
-
thin:
|
21
|
-
|
22
|
-
|
20
|
+
thin: "/tmp/rftpd-environment-thin.log"
|
21
|
+
queue: "/tmp/rftpd-environment-core.log"
|
22
|
+
api: "/tmp/rftpd-environment-core.log"
|
23
|
+
workers: "/tmp/rftpd-environment-work.log"
|
24
|
+
notify: "/tmp/rftpd-environment-work.log"
|
23
25
|
|
24
26
|
preprod:
|
25
27
|
<<: *defaults
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-ftp-daemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.100'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno MEDICI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -203,7 +203,6 @@ files:
|
|
203
203
|
- lib/rest-ftp-daemon/api/root.rb
|
204
204
|
- lib/rest-ftp-daemon/api/routes.rb
|
205
205
|
- lib/rest-ftp-daemon/api/status.rb
|
206
|
-
- lib/rest-ftp-daemon/common.rb
|
207
206
|
- lib/rest-ftp-daemon/config.rb
|
208
207
|
- lib/rest-ftp-daemon/constants.rb
|
209
208
|
- lib/rest-ftp-daemon/exceptions.rb
|
@@ -211,6 +210,7 @@ files:
|
|
211
210
|
- lib/rest-ftp-daemon/job.rb
|
212
211
|
- lib/rest-ftp-daemon/job_queue.rb
|
213
212
|
- lib/rest-ftp-daemon/logger.rb
|
213
|
+
- lib/rest-ftp-daemon/logger_pool.rb
|
214
214
|
- lib/rest-ftp-daemon/notification.rb
|
215
215
|
- lib/rest-ftp-daemon/static/css/bootstrap.css
|
216
216
|
- lib/rest-ftp-daemon/static/css/main.css
|