rest-ftp-daemon 0.250.5 → 0.300.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -14
- data/README.md +12 -3
- data/bin/rest-ftp-daemon +102 -96
- data/config.ru +5 -5
- data/defaults.yml +61 -0
- data/lib/rest-ftp-daemon.rb +10 -4
- data/lib/rest-ftp-daemon/api/config.rb +3 -2
- data/lib/rest-ftp-daemon/api/dashboard.rb +1 -4
- data/lib/rest-ftp-daemon/api/debug.rb +30 -17
- data/lib/rest-ftp-daemon/api/job_presenter.rb +0 -2
- data/lib/rest-ftp-daemon/api/jobs.rb +4 -3
- data/lib/rest-ftp-daemon/api/root.rb +7 -10
- data/lib/rest-ftp-daemon/api/status.rb +7 -13
- data/lib/rest-ftp-daemon/constants.rb +27 -45
- data/lib/rest-ftp-daemon/counters.rb +0 -4
- data/lib/rest-ftp-daemon/helpers.rb +3 -18
- data/lib/rest-ftp-daemon/job.rb +16 -21
- data/lib/rest-ftp-daemon/job_queue.rb +21 -14
- data/lib/rest-ftp-daemon/launcher.rb +26 -0
- data/lib/rest-ftp-daemon/logger_pool.rb +9 -19
- data/lib/rest-ftp-daemon/metrics.rb +41 -0
- data/lib/rest-ftp-daemon/notification.rb +7 -10
- data/lib/rest-ftp-daemon/remote.rb +4 -4
- data/lib/rest-ftp-daemon/remote_ftp.rb +10 -10
- data/lib/rest-ftp-daemon/remote_sftp.rb +13 -24
- data/lib/rest-ftp-daemon/views/dashboard.haml +2 -2
- data/lib/rest-ftp-daemon/views/dashboard_footer.haml +2 -2
- data/lib/rest-ftp-daemon/views/dashboard_header.haml +2 -2
- data/lib/rest-ftp-daemon/views/dashboard_workers.haml +2 -2
- data/lib/rest-ftp-daemon/worker.rb +43 -12
- data/lib/rest-ftp-daemon/worker_conchita.rb +15 -28
- data/lib/rest-ftp-daemon/worker_job.rb +30 -21
- data/lib/rest-ftp-daemon/worker_pool.rb +59 -50
- data/lib/rest-ftp-daemon/worker_reporter.rb +70 -0
- data/lib/shared/conf.rb +195 -0
- data/lib/shared/logger_formatter.rb +31 -0
- data/lib/shared/logger_helper.rb +78 -0
- data/rest-ftp-daemon.gemspec +23 -22
- data/{rest-ftp-daemon.yml.sample → rest-ftp-daemon.sample.yml} +10 -7
- data/spec/spec_helper.rb +1 -1
- metadata +30 -12
- data/lib/rest-ftp-daemon/logger.rb +0 -57
- data/lib/rest-ftp-daemon/logger_helper.rb +0 -36
- data/lib/rest-ftp-daemon/settings.rb +0 -57
data/spec/spec_helper.rb
CHANGED
@@ -2,8 +2,8 @@ require "pathname"
|
|
2
2
|
require "http"
|
3
3
|
require "pry"
|
4
4
|
|
5
|
-
require_relative "support/request_helpers"
|
6
5
|
require_relative "../lib/rest-ftp-daemon/constants"
|
6
|
+
require_relative "support/request_helpers"
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
9
|
# rspec-expectations config goes here. You can use an alternate
|
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.300.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno MEDICI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: http
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1
|
103
|
+
version: '1'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1
|
110
|
+
version: '1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: grape
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: chamber
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: haml
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -281,6 +295,7 @@ files:
|
|
281
295
|
- Rakefile
|
282
296
|
- bin/rest-ftp-daemon
|
283
297
|
- config.ru
|
298
|
+
- defaults.yml
|
284
299
|
- lib/rest-ftp-daemon.rb
|
285
300
|
- lib/rest-ftp-daemon/api/config.rb
|
286
301
|
- lib/rest-ftp-daemon/api/dashboard.rb
|
@@ -296,9 +311,9 @@ files:
|
|
296
311
|
- lib/rest-ftp-daemon/helpers.rb
|
297
312
|
- lib/rest-ftp-daemon/job.rb
|
298
313
|
- lib/rest-ftp-daemon/job_queue.rb
|
299
|
-
- lib/rest-ftp-daemon/
|
300
|
-
- lib/rest-ftp-daemon/logger_helper.rb
|
314
|
+
- lib/rest-ftp-daemon/launcher.rb
|
301
315
|
- lib/rest-ftp-daemon/logger_pool.rb
|
316
|
+
- lib/rest-ftp-daemon/metrics.rb
|
302
317
|
- lib/rest-ftp-daemon/notification.rb
|
303
318
|
- lib/rest-ftp-daemon/paginate.rb
|
304
319
|
- lib/rest-ftp-daemon/patch_haml.rb
|
@@ -306,7 +321,6 @@ files:
|
|
306
321
|
- lib/rest-ftp-daemon/remote.rb
|
307
322
|
- lib/rest-ftp-daemon/remote_ftp.rb
|
308
323
|
- lib/rest-ftp-daemon/remote_sftp.rb
|
309
|
-
- lib/rest-ftp-daemon/settings.rb
|
310
324
|
- lib/rest-ftp-daemon/static/css/bootstrap.css
|
311
325
|
- lib/rest-ftp-daemon/static/css/main.css
|
312
326
|
- lib/rest-ftp-daemon/uri.rb
|
@@ -323,8 +337,12 @@ files:
|
|
323
337
|
- lib/rest-ftp-daemon/worker_conchita.rb
|
324
338
|
- lib/rest-ftp-daemon/worker_job.rb
|
325
339
|
- lib/rest-ftp-daemon/worker_pool.rb
|
340
|
+
- lib/rest-ftp-daemon/worker_reporter.rb
|
341
|
+
- lib/shared/conf.rb
|
342
|
+
- lib/shared/logger_formatter.rb
|
343
|
+
- lib/shared/logger_helper.rb
|
326
344
|
- rest-ftp-daemon.gemspec
|
327
|
-
- rest-ftp-daemon.yml
|
345
|
+
- rest-ftp-daemon.sample.yml
|
328
346
|
- spec/rest-ftp-daemon/features/dashboard_spec.rb
|
329
347
|
- spec/rest-ftp-daemon/features/debug_spec.rb
|
330
348
|
- spec/rest-ftp-daemon/features/jobs_spec.rb
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require "logger"
|
2
|
-
|
3
|
-
class Logger
|
4
|
-
|
5
|
-
def info_with_id message, context = {}
|
6
|
-
# Ensure context is a hash of options and init
|
7
|
-
context = {} unless context.is_a? Hash
|
8
|
-
context[:level] ||= Logger::DEBUG
|
9
|
-
|
10
|
-
# Build prefixes depending on this context
|
11
|
-
prefix1 = build_prefix(context)
|
12
|
-
prefix2 = build_prefix + " | "
|
13
|
-
|
14
|
-
lines = context[:lines]
|
15
|
-
|
16
|
-
if lines.is_a? Hash
|
17
|
-
output = build_from_hash prefix2, lines
|
18
|
-
elsif lines.is_a? Array
|
19
|
-
output = build_from_array prefix2, lines
|
20
|
-
else
|
21
|
-
output = []
|
22
|
-
end
|
23
|
-
|
24
|
-
# Prepend plain message to output
|
25
|
-
output.unshift prefix1 + message.force_encoding(Encoding::UTF_8)
|
26
|
-
|
27
|
-
# Send all this to logger
|
28
|
-
add context[:level], output
|
29
|
-
end
|
30
|
-
|
31
|
-
def build_prefix context = {}
|
32
|
-
LOG_FORMAT_MESSAGE % [
|
33
|
-
context[:wid].to_s,
|
34
|
-
context[:jid].to_s,
|
35
|
-
context[:id].to_s,
|
36
|
-
context[:level].to_i + 1,
|
37
|
-
]
|
38
|
-
end
|
39
|
-
|
40
|
-
protected
|
41
|
-
|
42
|
-
def build_from_array prefix, lines
|
43
|
-
lines.map do |value|
|
44
|
-
#text = value.to_s.strip[0..LOG_TRIM_LINE]
|
45
|
-
text = value.to_s[0..LOG_TRIM_LINE]
|
46
|
-
"#{prefix}#{text}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def build_from_hash prefix, lines
|
51
|
-
lines.map do |name, value|
|
52
|
-
text = value.to_s.strip[0..LOG_TRIM_LINE]
|
53
|
-
"#{prefix}#{name}: #{text}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "logger"
|
2
|
-
|
3
|
-
module RestFtpDaemon
|
4
|
-
module LoggerHelper
|
5
|
-
|
6
|
-
protected
|
7
|
-
|
8
|
-
def log_info message, lines = []
|
9
|
-
log message, lines, Logger::INFO
|
10
|
-
end
|
11
|
-
|
12
|
-
def log_error message, lines = []
|
13
|
-
log message, lines, Logger::ERROR
|
14
|
-
end
|
15
|
-
|
16
|
-
def log_debug message, lines = []
|
17
|
-
log message, lines, Logger::DEBUG
|
18
|
-
end
|
19
|
-
|
20
|
-
def log_context
|
21
|
-
{}
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def log message, lines, level
|
27
|
-
context = log_context || {}
|
28
|
-
logger.info_with_id message, context.merge({
|
29
|
-
from: self.class.to_s,
|
30
|
-
lines: lines,
|
31
|
-
level: level,
|
32
|
-
})
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require "settingslogic"
|
2
|
-
|
3
|
-
# Configuration class
|
4
|
-
class Settings < Settingslogic
|
5
|
-
# Read configuration
|
6
|
-
namespace APP_ENV
|
7
|
-
source File.exist?(APP_CONF) ? APP_CONF : Hash.new
|
8
|
-
suppress_errors true
|
9
|
-
|
10
|
-
# Direct access to any depth
|
11
|
-
def at *path
|
12
|
-
path.reduce(Settings) { |m, key| m && m[key.to_s] }
|
13
|
-
end
|
14
|
-
|
15
|
-
# Dump whole settings set to readable YAML
|
16
|
-
def dump
|
17
|
-
to_hash.to_yaml(indent: 4, useheader: true, useversion: false )
|
18
|
-
end
|
19
|
-
|
20
|
-
def newrelic_enabled?
|
21
|
-
Settings.at(:newrelic)
|
22
|
-
end
|
23
|
-
|
24
|
-
def init_defaults
|
25
|
-
# Init host if missing
|
26
|
-
Settings["host"] ||= `hostname`.to_s.chomp.split(".").first
|
27
|
-
|
28
|
-
# Init PID file name if missing
|
29
|
-
Settings["pidfile"] ||= "/tmp/#{APP_NICK}-#{Settings['host']}-#{Settings['port']}.pid"
|
30
|
-
|
31
|
-
# Init NEWRELIC env
|
32
|
-
if Settings.newrelic_enabled?
|
33
|
-
# Enable module
|
34
|
-
ENV["NEWRELIC_AGENT_ENABLED"] = "true"
|
35
|
-
ENV["NEW_RELIC_MONITOR_MODE"] = "true"
|
36
|
-
|
37
|
-
# License
|
38
|
-
ENV["NEW_RELIC_LICENSE_KEY"] = Settings.at(:newrelic, :licence)
|
39
|
-
|
40
|
-
# Appname
|
41
|
-
platform = Settings.newrelic[:platform] || Settings["host"]
|
42
|
-
Settings.newrelic[:app_name] ||= "#{APP_NICK}-#{platform}-#{Settings.namespace}"
|
43
|
-
ENV["NEW_RELIC_APP_NAME"] = Settings.newrelic[:app_name]
|
44
|
-
|
45
|
-
# Logfile
|
46
|
-
ENV["NEW_RELIC_LOG"] = Settings.at(:logs, :newrelic)
|
47
|
-
else
|
48
|
-
ENV["NEWRELIC_AGENT_ENABLED"] = "false"
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
def overwrite options
|
54
|
-
Settings.merge!(options) if options.is_a? Enumerable
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|