rest-ftp-daemon 0.100.2 → 0.101

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a45abd6abf0d38a6dca977c42e81c1cf538dbd77
4
- data.tar.gz: a0d3f0fd02e570f9f0f3d56ae403607e0d854a43
3
+ metadata.gz: b3c42331f0e483617809300fcc7b6623e94e617b
4
+ data.tar.gz: 0184e556177357a18e19a686d3fc3ae852dcbffd
5
5
  SHA512:
6
- metadata.gz: f3d570450921acd5a1c8d0c61c89ad6ce6b0a97be868e74f3cacf654b3a7695e055345aa3111ca74f068572786b9d52fdbcaa1c2315efee26f8c924211890707
7
- data.tar.gz: 733164d4039e1660d50850b889c17704718a65097337d9a9b368ea1b3fc29879e67d4ef27e597a102b8775a1c58ec4dc8461bb81d8be2c790b393bce31d02ca3
6
+ metadata.gz: ead761e0002d4cfda4409fd43dd1c5828040b204fadb2286898c31ccd428edc41be0dd3c83a334d4c0c35770c5bd77856c3665279b539ca3614460990e5b78c6
7
+ data.tar.gz: 0518b79a4037e122c99d6ce50e660724f1db21693c0e5abfeeab319f6759dfce66461aaf7bc999500e967f833c67660fbadfa6a00f241be65c6b154099021ab7
data/bin/rest-ftp-daemon CHANGED
@@ -18,8 +18,9 @@ puts
18
18
  options = {}
19
19
  parser = OptionParser.new do |opts|
20
20
  opts.banner = "Usage: #{File.basename $0} [options] start|stop|restart"
21
+ opts.on("-c", "--config CONFIGFILE") { |config| APP_CONF = config }
21
22
  opts.on("-e", "--environment ENV") { |env| APP_ENV = env }
22
- opts.on("", "--dev") { APP_ENV = "development" }
23
+ opts.on("", "--dev") { APP_ENV = "development" }
23
24
  opts.on("-p", "--port PORT", "use PORT") { |port| options["port"] = port.to_i }
24
25
  opts.on("-w", "--workers COUNT", "Use COUNT worker threads") { |count| options["workers"] = count.to_i }
25
26
  opts.on("-d", "--daemonize", "Run daemonized in the background") { |bool| options["daemonize"] = true }
@@ -28,27 +29,31 @@ parser = OptionParser.new do |opts|
28
29
  opts.on("-u", "--user NAME", "User to run daemon as (use with -g)") { |user| options["user"] = user }
29
30
  opts.on("-g", "--group NAME", "Group to run daemon as (use with -u)"){ |group| options["group"] = group }
30
31
  opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
31
- opts.on_tail('-v', '--version', "Show version (#{APP_VER})") { puts APP_VER; exit }
32
+ opts.on_tail('-v', '--version', "Show version (#{APP_VER})") { puts APP_VER; exit }
32
33
  end
33
34
  begin
34
35
  parser.order!(ARGV)
35
36
  command = ARGV.shift
36
37
  unless ["start", "stop", "restart"].include? command
37
38
  puts parser
38
- exit 1
39
+ exit 11
39
40
  end
40
41
  rescue OptionParser::InvalidOption => e
41
42
  puts "EXITING: option parser: #{e.message}"
42
- exit 1
43
+ exit 12
43
44
  end
44
45
 
45
- # Load helpers and config
46
- app_root = File.dirname(__FILE__) + '/../'
46
+ # Build configuration file path from options
47
+ APP_CONF ||= File.expand_path "/etc/#{APP_NAME}.yml"
48
+ unless File.exists? APP_CONF
49
+ puts "EXITING: cannot read configuration file: #{APP_CONF}"
50
+ exit 13
51
+ end
52
+
53
+ # Load helpers and config, and merge options from ARGV into settings
47
54
  [:helpers, :config].each do |lib|
48
55
  require File.expand_path("#{app_root}/lib/rest-ftp-daemon/#{lib.to_s}")
49
56
  end
50
-
51
- # Merge options from ARGV into settings
52
57
  Settings.merge!(options)
53
58
 
54
59
  # Display compiled configuration
@@ -67,10 +72,10 @@ puts
67
72
  if ["start"].include? command
68
73
  if Settings['port'].nil?
69
74
  puts "ABORTING: Network port is missing"
70
- exit 1
75
+ exit 14
71
76
  elsif RestFtpDaemon::Helpers.local_port_used?(Settings['port'])
72
77
  puts "ABORTING: Network port #{Settings['port']} is already in use"
73
- exit 1
78
+ exit 15
74
79
  end
75
80
  end
76
81
 
@@ -8,8 +8,6 @@ require "facter"
8
8
  require "sys/cpu"
9
9
 
10
10
 
11
- # require 'celluloid/autostart'
12
-
13
11
  # My libs
14
12
  require 'rest-ftp-daemon/constants'
15
13
  require 'rest-ftp-daemon/config'
@@ -27,7 +27,6 @@ module RestFtpDaemon
27
27
  expose :exectime
28
28
 
29
29
  # Params
30
- # expose :wid, unless: lambda { |object, options| object.wid.nil? }
31
30
  expose :params, unless: :hide_params
32
31
 
33
32
  end
@@ -60,6 +60,7 @@ module RestFtpDaemon
60
60
  params do
61
61
  requires :source, type: String, desc: "Source file pattern"
62
62
  requires :target, type: String, desc: "Target remote path"
63
+ optional :label, type: String, desc: "Descriptive label for this job"
63
64
  optional :notify, type: String, desc: "URL to get POST'ed notifications back"
64
65
  optional :priority, type: Integer, desc: "Priority level of the job (lower is stronger)"
65
66
  optional :overwrite, type: Boolean, desc: "wether to overwrites files at target server",
@@ -69,8 +70,7 @@ module RestFtpDaemon
69
70
  end
70
71
 
71
72
  post '/jobs/' do
72
- info "POST /jobs"
73
- # #{params.inspect}"
73
+ info "POST /jobs #{params.inspect}"
74
74
  # request.body.rewind
75
75
  begin
76
76
 
@@ -99,7 +99,6 @@ module RestFtpDaemon
99
99
  end
100
100
  end
101
101
 
102
-
103
102
  end
104
103
  end
105
104
  end
@@ -20,7 +20,12 @@ module RestFtpDaemon
20
20
  ####### INITIALIZATION
21
21
 
22
22
  def initialize
23
+ # Call daddy
23
24
  super
25
+
26
+ # Check that Queue and Pool are available
27
+ raise RestFtpDaemon::MissingQueue unless defined? $queue
28
+ raise RestFtpDaemon::MissingQueue unless defined? $pool
24
29
  end
25
30
 
26
31
 
@@ -54,19 +59,6 @@ module RestFtpDaemon
54
59
 
55
60
  end
56
61
 
57
-
58
- ####### INITIALIZATION
59
-
60
- def initialize
61
- # Call daddy
62
- super
63
-
64
- # Check that Queue and Pool are available
65
- raise RestFtpDaemon::MissingQueue unless defined? $queue
66
- raise RestFtpDaemon::MissingQueue unless defined? $pool
67
- end
68
-
69
-
70
62
  end
71
63
  end
72
64
  end
@@ -1,7 +1,6 @@
1
1
  # Terrific constants
2
2
  APP_NAME = "rest-ftp-daemon"
3
- APP_CONF = "/etc/#{APP_NAME}.yml"
4
- APP_VER = "0.100.2"
3
+ APP_VER = "0.101"
5
4
 
6
5
  # Some global constants
7
6
  IDENT_JOB_LEN = 4
@@ -6,7 +6,7 @@ require 'timeout'
6
6
  module RestFtpDaemon
7
7
  class Job
8
8
 
9
- FIELDS = [:source, :target, :priority, :notify, :overwrite, :mkdir]
9
+ FIELDS = [:source, :target, :label, :priority, :notify, :overwrite, :mkdir]
10
10
 
11
11
  attr_reader :id
12
12
  attr_accessor :wid
@@ -32,7 +32,6 @@ module RestFtpDaemon
32
32
 
33
33
  # Init context
34
34
  @id = job_id.to_s
35
- #set :id, job_id
36
35
  FIELDS.each do |field|
37
36
  instance_variable_set("@#{field.to_s}", params[field])
38
37
  end
@@ -62,9 +61,6 @@ module RestFtpDaemon
62
61
  end
63
62
 
64
63
  def close
65
- # Close logger
66
- # info "Job.close"
67
- #@logger.close
68
64
  end
69
65
 
70
66
  def process
@@ -308,7 +304,6 @@ module RestFtpDaemon
308
304
  ftp_connect_and_login
309
305
 
310
306
  # Connect remote server, login and chdir
311
- #path = '/' + Helpers.extract_dirname(@target_url.path).to_s
312
307
  path = Helpers.extract_dirname(@target_url.path).to_s
313
308
  ftp_chdir_or_buildpath path
314
309
 
@@ -334,6 +329,7 @@ module RestFtpDaemon
334
329
  @status = :disconnecting
335
330
 
336
331
  # Update counters and flags
332
+ $queue.counter_inc :jobs_finished
337
333
  $queue.counter_add :transferred, @transfer_total
338
334
  @finished_at = Time.now
339
335
  end
@@ -567,7 +563,6 @@ module RestFtpDaemon
567
563
  # Done
568
564
  set :source_processing, nil
569
565
  info "Job.ftp_transfer finished"
570
- $queue.counter_inc :jobs_finished
571
566
  end
572
567
 
573
568
  def client_notify signal, error = nil, status = {}
@@ -17,12 +17,10 @@ module RestFtpDaemon
17
17
  @mutex = Mutex.new
18
18
 
19
19
  # # Logger
20
- # @logger = RestFtpDaemon::Logger.new(:queue, "QUEUE")
21
20
  @logger = RestFtpDaemon::LoggerPool.instance.get :queue
22
21
 
23
22
  # Identifiers generator
24
23
  @last_id = 0
25
- #@prefix = SecureRandom.hex(IDENT_JOB_LEN)
26
24
  @prefix = Helpers.identifier IDENT_JOB_LEN
27
25
  info "queue initialized with prefix: #{@prefix}"
28
26
 
@@ -17,7 +17,6 @@ module RestFtpDaemon
17
17
  # Compute file path / STDERR
18
18
  logfile = Settings.logs[pipe] if Settings.logs.is_a? Hash
19
19
  logfile ||= STDERR
20
- #logfile ||= STDOUT
21
20
 
22
21
  # Create the logger and return it
23
22
  logger = Logger.new(logfile, 'daily') #, 10, 1024000)
@@ -15,7 +15,6 @@ module RestFtpDaemon
15
15
  @id = Helpers.identifier(IDENT_NOTIF_LEN)
16
16
 
17
17
  # Logger
18
- # @logger = RestFtpDaemon::Logger.new(:workers, "NOTIF #{key}")
19
18
  @logger = RestFtpDaemon::LoggerPool.instance.get :notify
20
19
 
21
20
  # Check context
@@ -42,9 +42,10 @@
42
42
 
43
43
  %table.table.table-striped.table-hover.table-condensed
44
44
  %tr
45
- %th JID
45
+ %th ID
46
46
  %th P
47
47
  %th W
48
+ %th label
48
49
  %th source
49
50
  %th target
50
51
  %th queued
@@ -16,7 +16,6 @@
16
16
  - else
17
17
  - trclass = "warning"
18
18
 
19
-
20
19
  %tr{class: trclass}
21
20
 
22
21
  %td{title: presented.to_json}= job.id
@@ -29,6 +28,8 @@
29
28
  - unless job.wid.nil?
30
29
  .label.label-default.flag.worker-label= job.wid
31
30
 
31
+ %td= job.label
32
+
32
33
  %td{title: job.get(:source_path)}
33
34
  =# Helpers.job_method_label job.get(:source_method)
34
35
  = Helpers.highlight_tokens job.source
@@ -1,7 +1,7 @@
1
1
  module RestFtpDaemon
2
2
  class WorkerPool
3
3
 
4
- attr_reader :requested, :processed, :wid
4
+ attr_reader :wid
5
5
 
6
6
  def initialize number_threads
7
7
  # Logger
@@ -8,8 +8,8 @@ defaults: &defaults
8
8
  host: <%= `hostname`.chomp.split('.').first %>
9
9
 
10
10
  transfer:
11
- #update_every_kb: 500
12
- #notify_after_sec: 10
11
+ update_every_kb: 1024
12
+ notify_after_sec: 10
13
13
 
14
14
  conchita:
15
15
  timer: 10
@@ -17,11 +17,11 @@ defaults: &defaults
17
17
  #clean_finished: 600
18
18
 
19
19
  logs:
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"
20
+ thin: "/var/log/rftpd-environment-thin.log"
21
+ queue: "/var/log/rftpd-environment-core.log"
22
+ api: "/var/log/rftpd-environment-core.log"
23
+ workers: "/var/log/rftpd-environment-work.log"
24
+ notify: "/var/log/rftpd-environment-work.log"
25
25
 
26
26
  preprod:
27
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.100.2
4
+ version: '0.101'
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 00:00:00.000000000 Z
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler