rest-ftp-daemon 0.302.3 → 0.304.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +14 -3
  3. data/README.md +1 -1
  4. data/bin/rest-ftp-daemon +3 -3
  5. data/config.ru +1 -1
  6. data/defaults.yml +2 -2
  7. data/lib/rest-ftp-daemon/api/root.rb +10 -4
  8. data/lib/rest-ftp-daemon/api/status.rb +10 -0
  9. data/lib/rest-ftp-daemon/constants.rb +1 -4
  10. data/lib/rest-ftp-daemon/counters.rb +4 -2
  11. data/lib/rest-ftp-daemon/job.rb +11 -12
  12. data/lib/rest-ftp-daemon/job_queue.rb +10 -12
  13. data/lib/rest-ftp-daemon/launcher.rb +1 -0
  14. data/lib/rest-ftp-daemon/metrics.rb +10 -0
  15. data/lib/rest-ftp-daemon/notification.rb +5 -5
  16. data/lib/rest-ftp-daemon/paginate.rb +1 -0
  17. data/lib/rest-ftp-daemon/path.rb +2 -0
  18. data/lib/rest-ftp-daemon/remote.rb +5 -4
  19. data/lib/rest-ftp-daemon/remote_ftp.rb +3 -1
  20. data/lib/rest-ftp-daemon/remote_sftp.rb +4 -2
  21. data/lib/rest-ftp-daemon/views/dashboard_workers.haml +4 -1
  22. data/lib/rest-ftp-daemon/worker_pool.rb +6 -7
  23. data/lib/rest-ftp-daemon/workers/conchita.rb +8 -7
  24. data/lib/rest-ftp-daemon/workers/reporter.rb +24 -12
  25. data/lib/rest-ftp-daemon/workers/transfer.rb +8 -7
  26. data/lib/rest-ftp-daemon/workers/worker.rb +12 -0
  27. data/lib/rest-ftp-daemon.rb +10 -16
  28. data/lib/{rest-ftp-daemon → shared}/patch_array.rb +0 -0
  29. data/lib/{rest-ftp-daemon → shared}/patch_haml.rb +0 -2
  30. data/rest-ftp-daemon.gemspec +29 -28
  31. metadata +34 -24
  32. data/lib/rest-ftp-daemon/logger_pool.rb +0 -61
  33. data/lib/shared/conf.rb +0 -201
  34. data/lib/shared/logger_formatter.rb +0 -31
  35. data/lib/shared/logger_helper.rb +0 -78
  36. data/lib/shared/worker_base.rb +0 -112
@@ -1,112 +0,0 @@
1
- module Shared
2
- class WorkerBase
3
- include Shared::LoggerHelper
4
- attr_reader :logger
5
- attr_reader :pool
6
- attr_reader :wid
7
-
8
- def initialize wid, pool = nil
9
- # Logger
10
- @logger = RestFtpDaemon::LoggerPool.instance.get :workers
11
- @log_worker_status_changes = true
12
-
13
- # Configuration
14
- @config = {}
15
-
16
- # Set thread context
17
- @pool = pool
18
- @wid = wid
19
- Thread.current.thread_variable_set :pool, pool
20
- Thread.current.thread_variable_set :wid, wid
21
- Thread.current.thread_variable_set :started_at, Time.now
22
- worker_status WORKER_STATUS_STARTING
23
-
24
- # Ask worker to init itself, and return if there are errors
25
- if worker_init_result = worker_init
26
- log_error "worker_init aborting: #{worker_init_result.inspect}", @config
27
- else
28
- # We're ok, let's start out loop
29
- start_loop
30
- end
31
- end
32
-
33
- protected
34
-
35
- # Worker methods prototypes
36
- def worker_init
37
- end
38
- def worker_after
39
- end
40
- def worker_process
41
- end
42
- def worker_config
43
- end
44
-
45
- def log_prefix
46
- [
47
- Thread.current.thread_variable_get(:wid),
48
- Thread.current.thread_variable_get(:jid),
49
- nil
50
- ]
51
- end
52
-
53
- def start_loop
54
- log_info "start_loop starting", @config
55
- loop do
56
- begin
57
- # Do the hard work
58
- worker_process
59
-
60
- # Do the cleaning/sleeping stuff
61
- worker_after
62
-
63
- rescue StandardError => e
64
- log_error "WORKER EXCEPTION: #{e.inspect}"
65
- sleep 1
66
- end
67
- end
68
- end
69
-
70
- def worker_status status, job = nil
71
- # Update thread variables
72
- Thread.current.thread_variable_set :status, status
73
- Thread.current.thread_variable_set :updated_at, Time.now
74
-
75
- # Nothin' to log if "silent"
76
- return unless @log_worker_status_changes
77
-
78
- # Log this status change
79
- if job.is_a?(Job)
80
- log_info "status [#{status}] on job[#{job.id}] status[#{job.status}] error[#{job.error}]"
81
- else
82
- log_info "status [#{status}]"
83
- end
84
- end
85
-
86
- def worker_jid jid
87
- Thread.current.thread_variable_set :jid, jid
88
- Thread.current.thread_variable_set :updated_at, Time.now
89
- end
90
-
91
- def config_section key
92
- # Debugging
93
- @log_worker_status_changes = @debug
94
-
95
- # Set my configuration
96
- if (Conf[key].is_a? Hash) && Conf[key]
97
- @config = Conf[key]
98
- else
99
- log_error "missing [#{key}] configuration"
100
- end
101
- end
102
-
103
- # NewRelic instrumentation
104
- if Conf.newrelic_enabled?
105
- include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
106
- add_transaction_tracer :worker_init, category: :task
107
- add_transaction_tracer :worker_after, category: :task
108
- add_transaction_tracer :worker_process, category: :task
109
- end
110
-
111
- end
112
- end