rest-ftp-daemon 0.210.2 → 0.212.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -1
- data/bin/rest-ftp-daemon +26 -18
- data/config.ru +3 -0
- data/lib/rest-ftp-daemon/api/debug.rb +20 -1
- data/lib/rest-ftp-daemon/api/status.rb +6 -2
- data/lib/rest-ftp-daemon/constants.rb +2 -1
- data/lib/rest-ftp-daemon/job.rb +15 -8
- data/lib/rest-ftp-daemon/job_queue.rb +10 -5
- data/lib/rest-ftp-daemon/settings.rb +27 -7
- data/lib/rest-ftp-daemon/views/dashboard_headers.haml +14 -9
- data/lib/rest-ftp-daemon/views/dashboard_jobs.haml +2 -2
- data/lib/rest-ftp-daemon/views/dashboard_table.haml +11 -14
- data/lib/rest-ftp-daemon/worker_pool.rb +18 -5
- data/lib/rest-ftp-daemon.rb +3 -0
- data/rest-ftp-daemon.gemspec +4 -0
- data/rest-ftp-daemon.yml.sample +7 -3
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e2cba7fe2218d3f261566678feba235343ca4a
|
4
|
+
data.tar.gz: 75c4001a985741740c66165c6b1d73a893d0e43a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 695516939d86fe5e962458758dfe2ce3aa34b5c80ca8eec9bd3ccc4f893c303f9fac4489eec4368cc0ab469d53c584654573e938ad6b90a37c42795f3c1d85ce
|
7
|
+
data.tar.gz: 72cdbba9f002f17faa9e6c0d203c089b89e5eb9a57cc32e892287ebe620e4e4c96f1234fc54ca0087e1cfe733ba7da3290c247c93f1f07cf1d1ec269f7ee6361
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rest-ftp-daemon (0.
|
4
|
+
rest-ftp-daemon (0.212.0)
|
5
5
|
double-bag-ftps
|
6
6
|
facter
|
7
|
+
get_process_mem
|
7
8
|
grape
|
8
9
|
grape-entity
|
9
10
|
haml
|
10
11
|
json
|
12
|
+
newrelic_rpm
|
11
13
|
settingslogic
|
12
14
|
sys-cpu
|
13
15
|
thin (~> 1.6)
|
@@ -39,6 +41,7 @@ GEM
|
|
39
41
|
facter (2.4.1)
|
40
42
|
CFPropertyList (~> 2.2.6)
|
41
43
|
ffi (1.9.8)
|
44
|
+
get_process_mem (0.2.0)
|
42
45
|
grape (0.11.0)
|
43
46
|
activesupport
|
44
47
|
builder
|
@@ -61,6 +64,7 @@ GEM
|
|
61
64
|
minitest (5.5.1)
|
62
65
|
multi_json (1.11.0)
|
63
66
|
multi_xml (0.5.5)
|
67
|
+
newrelic_rpm (3.11.1.284)
|
64
68
|
rack (1.6.0)
|
65
69
|
rack-accept (0.4.5)
|
66
70
|
rack (>= 0.4)
|
data/bin/rest-ftp-daemon
CHANGED
@@ -6,9 +6,10 @@ begin
|
|
6
6
|
require "thin"
|
7
7
|
require 'optparse'
|
8
8
|
require 'socket'
|
9
|
-
require 'timeout'
|
9
|
+
# require 'timeout'
|
10
|
+
require "settingslogic"
|
10
11
|
rescue LoadError
|
11
|
-
raise "EXITING: some of basic libs were not found: thin, optparse, socket,
|
12
|
+
raise "EXITING: some of basic libs were not found: thin, optparse, socket, settingslogic"
|
12
13
|
end
|
13
14
|
|
14
15
|
|
@@ -50,17 +51,26 @@ else
|
|
50
51
|
end
|
51
52
|
|
52
53
|
|
53
|
-
#
|
54
|
+
# Load config, and merge options from ARGV into settings
|
54
55
|
APP_CONF ||= File.expand_path "/etc/#{APP_NAME}.yml"
|
55
56
|
abort "EXITING: cannot read configuration file: #{APP_CONF}" unless File.exists? APP_CONF
|
56
|
-
|
57
|
-
|
58
|
-
# Load config, and merge options from ARGV into settings
|
59
57
|
begin
|
58
|
+
# Import settings
|
60
59
|
require File.expand_path("#{app_root}/lib/rest-ftp-daemon/settings")
|
60
|
+
|
61
|
+
# Set defaults
|
62
|
+
Settings.init_defaults
|
63
|
+
|
64
|
+
# Overwrite with commandline options
|
61
65
|
Settings.merge!(options)
|
66
|
+
|
67
|
+
# Init NewRelic
|
68
|
+
Settings.init_newrelic
|
69
|
+
|
62
70
|
rescue Psych::SyntaxError => e
|
63
71
|
abort "EXITING: config file syntax error: #{e.message}"
|
72
|
+
rescue Exception => e
|
73
|
+
abort "EXITING: unknow error loading settings #{e.inspect}"
|
64
74
|
end
|
65
75
|
|
66
76
|
|
@@ -84,30 +94,28 @@ argv << ["--log", Settings.at(:logs, :thin)]
|
|
84
94
|
argv << ["--daemonize"] if [1, true].include? Settings.daemonize
|
85
95
|
|
86
96
|
|
87
|
-
# ARGV: logging
|
97
|
+
# ARGV: logging, user and group, command
|
88
98
|
if (logfile = Settings.at :logs, :thin)
|
89
99
|
argv << ["--log", logfile] if logfile
|
90
100
|
end
|
91
|
-
|
92
|
-
# ARGV: user and group
|
93
101
|
if Settings.user && Settings.group
|
94
102
|
argv << ["--user", Settings.user]
|
95
103
|
argv << ["--group", Settings.group]
|
96
104
|
end
|
97
|
-
|
98
|
-
|
99
|
-
# ARGV: add command
|
100
105
|
argv << command unless command.nil?
|
101
106
|
|
107
|
+
|
102
108
|
# Display final configuration
|
103
109
|
puts "--- #{APP_NAME} #{APP_VER}"
|
104
110
|
puts "Config file \t #{APP_CONF}"
|
105
111
|
puts "PID file \t #{Settings.pidfile}"
|
106
|
-
puts "Daemonize \t #{Settings.daemonize ? 'YES' : "no"}"
|
112
|
+
puts "Daemonize \t #{Settings.daemonize ? 'YES' : "no (PID: #{Process.pid})"}"
|
113
|
+
puts "Host \t #{Settings.host}"
|
107
114
|
puts "Namespace \t #{Settings.namespace}"
|
108
115
|
puts "Network port \t #{Settings.port}"
|
109
116
|
puts "User:group \t #{Settings.user}:#{Settings.group}" if (Settings.user || Settings.group)
|
110
|
-
puts Settings.
|
117
|
+
puts "Newrelic \t #{Settings.newrelic_enabled? ? Settings.newrelic.inspect : "no"}"
|
118
|
+
# puts Settings.dump
|
111
119
|
puts
|
112
120
|
puts "--- Thin ARGV"
|
113
121
|
puts argv.flatten.join(' ')
|
@@ -139,11 +147,11 @@ rescue SystemExit
|
|
139
147
|
begin
|
140
148
|
Process.kill(0, pid)
|
141
149
|
puts "Process ##{pid} is running"
|
142
|
-
rescue Errno::EPERM
|
143
|
-
|
150
|
+
rescue Errno::EPERM # changed uid
|
151
|
+
puts "No permission to query process ##{pid}!";
|
144
152
|
rescue Errno::ESRCH
|
145
|
-
|
153
|
+
puts "Process ##{pid} is NOT running."; # or zombied
|
146
154
|
rescue
|
147
|
-
|
155
|
+
puts "Unable to determine status for ##{pid}: #{$!}"
|
148
156
|
end
|
149
157
|
end
|
data/config.ru
CHANGED
@@ -4,7 +4,7 @@ module RestFtpDaemon
|
|
4
4
|
|
5
5
|
####### GET /debug
|
6
6
|
|
7
|
-
get '/
|
7
|
+
get '/raise' do
|
8
8
|
info "GET /debug"
|
9
9
|
begin
|
10
10
|
raise RestFtpDaemon::DummyException
|
@@ -20,6 +20,25 @@ module RestFtpDaemon
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
# get '/memsize' do
|
24
|
+
# info "GET /memsize"
|
25
|
+
# ObjectSpace.each_object do |e|
|
26
|
+
# #puts
|
27
|
+
# print ObjectSpace.memsize_of(e)
|
28
|
+
# print "\t"
|
29
|
+
# print e.class.to_s
|
30
|
+
# print "\t"
|
31
|
+
# puts e.inspect[0..80]
|
32
|
+
# # puts ({
|
33
|
+
# # klass: e.class,
|
34
|
+
# # size: ObjectSpace.memsize_of(e),
|
35
|
+
# # }.inspect)
|
36
|
+
# # puts
|
37
|
+
# end
|
38
|
+
# status 200
|
39
|
+
# []
|
40
|
+
# end
|
41
|
+
|
23
42
|
end
|
24
43
|
end
|
25
44
|
end
|
@@ -8,18 +8,22 @@ module RestFtpDaemon
|
|
8
8
|
# Server global status
|
9
9
|
get '/status' do
|
10
10
|
info "GET /status"
|
11
|
+
mem = GetProcessMem.new
|
12
|
+
|
11
13
|
status 200
|
12
14
|
return {
|
13
15
|
hostname: `hostname`.chomp,
|
14
16
|
version: APP_VER,
|
15
|
-
config: Helpers.get_censored_config,
|
16
17
|
started: APP_STARTED,
|
17
18
|
uptime: (Time.now - APP_STARTED).round(1),
|
18
19
|
counters: $queue.counters,
|
20
|
+
memory_bytes: mem.bytes.to_i,
|
21
|
+
memory_mb: mem.mb.round(0),
|
19
22
|
status: $queue.counts_by_status,
|
20
23
|
workers: $pool.worker_variables,
|
21
24
|
jobs_count: $queue.jobs_count,
|
22
|
-
jobs_queued: $queue.queued_ids
|
25
|
+
jobs_queued: $queue.queued_ids,
|
26
|
+
config: Helpers.get_censored_config,
|
23
27
|
#routes: RestFtpDaemon::API::Root::routes,
|
24
28
|
}
|
25
29
|
end
|
data/lib/rest-ftp-daemon/job.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module RestFtpDaemon
|
2
2
|
class Job
|
3
3
|
|
4
|
+
if Settings.newrelic_enabled?
|
5
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
6
|
+
end
|
7
|
+
|
4
8
|
FIELDS = [:source, :target, :label, :priority, :notify, :overwrite, :mkdir, :tempfile]
|
5
9
|
|
6
10
|
attr_accessor :wid
|
@@ -20,7 +24,6 @@ module RestFtpDaemon
|
|
20
24
|
attr_reader name
|
21
25
|
end
|
22
26
|
|
23
|
-
|
24
27
|
def initialize job_id, params={}
|
25
28
|
# Call super
|
26
29
|
# super()
|
@@ -134,7 +137,7 @@ module RestFtpDaemon
|
|
134
137
|
rescue Errno::ECONNREFUSED => exception
|
135
138
|
return oops :ended, exception, :conn_refused
|
136
139
|
|
137
|
-
rescue Timeout::Error, Errno::ETIMEDOUT => exception
|
140
|
+
rescue Timeout::Error, Errno::ETIMEDOUT, Net::ReadTimeout => exception
|
138
141
|
return oops :ended, exception, :conn_timed_out
|
139
142
|
|
140
143
|
rescue OpenSSL::SSL::SSLError => exception
|
@@ -144,7 +147,7 @@ module RestFtpDaemon
|
|
144
147
|
return oops :ended, exception, :ftp_perm_error
|
145
148
|
|
146
149
|
rescue Net::FTPTempError => exception
|
147
|
-
return oops :ended, exception, :
|
150
|
+
return oops :ended, exception, :net_temp_error
|
148
151
|
|
149
152
|
rescue Errno::EMFILE => exception
|
150
153
|
return oops :ended, exception, :too_many_open_files
|
@@ -197,6 +200,11 @@ module RestFtpDaemon
|
|
197
200
|
@weight = [@priority.to_i, -@queued_at.to_i]
|
198
201
|
end
|
199
202
|
|
203
|
+
def exectime
|
204
|
+
return nil if (@started_at.nil? || @finished_at.nil?)
|
205
|
+
(@finished_at - @started_at).round(2)
|
206
|
+
end
|
207
|
+
|
200
208
|
def set_queued
|
201
209
|
# Update job status
|
202
210
|
newstatus JOB_STATUS_QUEUED
|
@@ -217,11 +225,6 @@ module RestFtpDaemon
|
|
217
225
|
(Time.now - @queued_at).round(2)
|
218
226
|
end
|
219
227
|
|
220
|
-
def exectime
|
221
|
-
return nil if (@started_at.nil? || @finished_at.nil?)
|
222
|
-
(@finished_at - @started_at).round(2)
|
223
|
-
end
|
224
|
-
|
225
228
|
def set attribute, value
|
226
229
|
@mutex.synchronize do
|
227
230
|
@params || {}
|
@@ -713,5 +716,9 @@ module RestFtpDaemon
|
|
713
716
|
client_notify event, error: error, status: notif_status
|
714
717
|
end
|
715
718
|
|
719
|
+
if Settings.newrelic_enabled?
|
720
|
+
add_transaction_tracer :process, :category => :task
|
721
|
+
end
|
722
|
+
|
716
723
|
end
|
717
724
|
end
|
@@ -9,6 +9,10 @@ module RestFtpDaemon
|
|
9
9
|
attr_reader :queue
|
10
10
|
attr_reader :jobs
|
11
11
|
|
12
|
+
if Settings.newrelic_enabled?
|
13
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
14
|
+
end
|
15
|
+
|
12
16
|
def initialize
|
13
17
|
# Instance variables
|
14
18
|
@queue = []
|
@@ -154,7 +158,7 @@ module RestFtpDaemon
|
|
154
158
|
alias << push
|
155
159
|
alias enq push
|
156
160
|
|
157
|
-
def pop
|
161
|
+
def pop non_block=false
|
158
162
|
@mutex.synchronize do
|
159
163
|
while true
|
160
164
|
if @queue.empty?
|
@@ -163,10 +167,6 @@ module RestFtpDaemon
|
|
163
167
|
@waiting.push Thread.current
|
164
168
|
@mutex.sleep
|
165
169
|
else
|
166
|
-
# Refresh queue order
|
167
|
-
# sort_queue!
|
168
|
-
|
169
|
-
# Extract the heaviest item in the queue
|
170
170
|
return @queue.pop
|
171
171
|
end
|
172
172
|
end
|
@@ -261,5 +261,10 @@ module RestFtpDaemon
|
|
261
261
|
origin: self.class.to_s
|
262
262
|
end
|
263
263
|
|
264
|
+
if Settings.newrelic_enabled?
|
265
|
+
add_transaction_tracer :push, :category => :task
|
266
|
+
add_transaction_tracer :pop, :category => :task
|
267
|
+
end
|
268
|
+
|
264
269
|
end
|
265
270
|
end
|
@@ -1,10 +1,3 @@
|
|
1
|
-
# Try to load Settingslogic
|
2
|
-
begin
|
3
|
-
require "settingslogic"
|
4
|
-
rescue LoadError
|
5
|
-
raise "warning: Settingslogic is needed to provide configuration values to the Gemspec file"
|
6
|
-
end
|
7
|
-
|
8
1
|
# Configuration class
|
9
2
|
class Settings < Settingslogic
|
10
3
|
# Read configuration
|
@@ -27,4 +20,31 @@ class Settings < Settingslogic
|
|
27
20
|
self.to_hash.to_yaml( :Indent => 4, :UseHeader => true, :UseVersion => false )
|
28
21
|
end
|
29
22
|
|
23
|
+
def init_defaults
|
24
|
+
Settings['host'] ||= `hostname`.chomp.split('.').first
|
25
|
+
end
|
26
|
+
|
27
|
+
def newrelic_enabled?
|
28
|
+
Settings.newrelic.is_a?(Hash) && Settings.at(:newrelic, :license)
|
29
|
+
end
|
30
|
+
|
31
|
+
def init_newrelic
|
32
|
+
# Skip if not enabled
|
33
|
+
return ENV['NEWRELIC_AGENT_ENABLED'] = 'false' unless Settings.newrelic_enabled?
|
34
|
+
|
35
|
+
# Enable module
|
36
|
+
ENV['NEWRELIC_AGENT_ENABLED'] = 'true'
|
37
|
+
ENV['NEW_RELIC_MONITOR_MODE'] = 'true'
|
38
|
+
#Settings['newrelic']['enabled'] = true
|
39
|
+
|
40
|
+
# License
|
41
|
+
ENV['NEW_RELIC_LICENSE_KEY'] = Settings.at(:newrelic, :license)
|
42
|
+
|
43
|
+
# Appname
|
44
|
+
ENV['NEW_RELIC_APP_NAME'] = Settings.at(:newrelic, :appname) || "#{APP_NICK}-#{Settings.host}-#{APP_ENV}"
|
45
|
+
|
46
|
+
# Logfile
|
47
|
+
ENV['NEW_RELIC_LOG'] = Settings.at(:logs, :newrelic)
|
48
|
+
end
|
49
|
+
|
30
50
|
end
|
@@ -2,33 +2,38 @@
|
|
2
2
|
- info_procs = (Facter.value :processorcount).to_i
|
3
3
|
- info_load = Sys::CPU.load_avg.first.to_f
|
4
4
|
- info_norm = info_procs.zero? ? "N/A" : (100 * info_load / info_procs).round(1)
|
5
|
+
- info_processed = $queue.counter_get(:jobs_processed)
|
6
|
+
- mem = GetProcessMem.new
|
5
7
|
|
6
8
|
|
7
9
|
.btn-group.btn-group-sm
|
8
|
-
.btn.btn-default.btn-success
|
9
|
-
.btn.btn-default=
|
10
|
+
.btn.btn-default.btn-success Host
|
11
|
+
.btn.btn-default= Settings.host
|
10
12
|
|
11
13
|
.btn-group.btn-group-sm
|
12
14
|
.btn.btn-default.btn-success IP
|
13
15
|
.btn.btn-default= Facter.value(:ipaddress)
|
14
16
|
|
15
17
|
.btn-group.btn-group-sm
|
16
|
-
.btn.btn-default.btn-success
|
17
|
-
.btn.btn-default=
|
18
|
+
.btn.btn-default.btn-success Cores
|
19
|
+
.btn.btn-default= info_procs
|
18
20
|
|
19
21
|
.btn-group.btn-group-sm
|
20
|
-
.btn.btn-default.btn-
|
22
|
+
.btn.btn-default.btn-warning Load
|
21
23
|
.btn.btn-default= info_load.round(1)
|
22
24
|
|
23
25
|
.btn-group.btn-group-sm
|
24
|
-
.btn.btn-default.btn-
|
26
|
+
.btn.btn-default.btn-warning CPU
|
25
27
|
.btn.btn-default= "#{info_norm} %"
|
26
28
|
|
27
29
|
.btn-group.btn-group-sm
|
28
|
-
.btn.btn-default.btn-
|
29
|
-
.btn.btn-default=
|
30
|
+
.btn.btn-default.btn-warning Mem
|
31
|
+
.btn.btn-default= Helpers.format_bytes(mem.bytes, "B")
|
32
|
+
|
33
|
+
.btn-group.btn-group-sm
|
34
|
+
.btn.btn-default.btn-info Processed
|
35
|
+
.btn.btn-default= Helpers.format_bytes(info_processed)
|
30
36
|
|
31
37
|
.btn-group.btn-group-sm
|
32
38
|
.btn.btn-default.btn-info Transferred
|
33
39
|
.btn.btn-default= Helpers.format_bytes(trans, "B")
|
34
|
-
|
@@ -1,13 +1,10 @@
|
|
1
1
|
- jobs.each do |job|
|
2
|
-
- size = job.get :transfer_total
|
3
|
-
- sent = job.get :transfer_sent
|
4
2
|
- progress = job.get :progress
|
5
3
|
- source_count = job.get(:source_count) || 0
|
6
4
|
- source_processed = job.get(:source_processed) || 0
|
7
5
|
- source_current = job.get(:source_current)
|
8
6
|
- presented = present job, :with => RestFtpDaemon::API::Entities::JobPresenter, hide_params: true
|
9
|
-
-
|
10
|
-
- method = job.get(:target_method)
|
7
|
+
- bitrate = job.get :transfer_bitrate
|
11
8
|
|
12
9
|
- trclass = JOB_STYLES[job.status]
|
13
10
|
|
@@ -25,7 +22,7 @@
|
|
25
22
|
= Helpers.highlight_tokens job.source
|
26
23
|
|
27
24
|
%td
|
28
|
-
= Helpers.job_method_label
|
25
|
+
= Helpers.job_method_label (job.get :target_method)
|
29
26
|
|
30
27
|
%td{title: job.get(:target_url)}
|
31
28
|
= Helpers.highlight_tokens job.target
|
@@ -45,28 +42,26 @@
|
|
45
42
|
- unless progress.nil?
|
46
43
|
%span.push-progress
|
47
44
|
= "#{progress}%"
|
48
|
-
|
49
45
|
%br
|
50
|
-
%
|
51
|
-
%
|
52
|
-
= source_current unless source_current.nil?
|
46
|
+
%span.push-filename
|
47
|
+
%b= source_current unless source_current.nil?
|
53
48
|
|
54
49
|
%td
|
55
50
|
- unless job.error || job.status == JOB_STATUS_FINISHED
|
56
51
|
.progress
|
57
52
|
.progress-bar{style:"width: #{progress}%;"}
|
58
53
|
=# "#{progress}%" unless progress.nil?
|
59
|
-
= Helpers.format_bytes(
|
54
|
+
= Helpers.format_bytes(job.get(:transfer_sent), "B")
|
60
55
|
|
61
56
|
- else
|
62
|
-
.error{title:
|
57
|
+
.error{title: job.get(:error_message)}
|
63
58
|
= Helpers.text_or_empty(job.error)
|
64
59
|
|
65
60
|
%td.nobr.text-right
|
66
|
-
= Helpers.format_bytes(
|
61
|
+
= Helpers.format_bytes(job.get(:transfer_total), "B")
|
67
62
|
|
68
|
-
%td.nobr.text-right
|
69
|
-
- if
|
63
|
+
%td.nobr.text-right{title: "time: #{job.exectime} s"}
|
64
|
+
- if bitrate
|
70
65
|
%span.push-bitrate
|
71
66
|
= Helpers.format_bytes(bitrate, "bps")
|
72
67
|
|
@@ -76,3 +71,5 @@
|
|
76
71
|
|
77
72
|
- unless job.wid.nil?
|
78
73
|
.label.label-warning.flag.worker-label= job.wid
|
74
|
+
|
75
|
+
|
@@ -3,6 +3,10 @@ module RestFtpDaemon
|
|
3
3
|
|
4
4
|
attr_reader :wid
|
5
5
|
|
6
|
+
if Settings.newrelic_enabled?
|
7
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
8
|
+
end
|
9
|
+
|
6
10
|
def initialize number_threads
|
7
11
|
# Logger
|
8
12
|
@logger = RestFtpDaemon::LoggerPool.instance.get :workers
|
@@ -37,7 +41,6 @@ module RestFtpDaemon
|
|
37
41
|
@workers[wid] && @workers[wid].alive?
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
44
|
private
|
42
45
|
|
43
46
|
def create_worker_threads n
|
@@ -55,17 +58,22 @@ module RestFtpDaemon
|
|
55
58
|
|
56
59
|
def create_worker_thread wid
|
57
60
|
Thread.new wid do
|
58
|
-
|
59
61
|
# Set thread context
|
60
62
|
Thread.current.thread_variable_set :wid, wid
|
61
63
|
Thread.current.thread_variable_set :started_at, Time.now
|
64
|
+
worker_status :starting
|
62
65
|
|
63
66
|
# Start working
|
64
|
-
worker_status :starting
|
65
67
|
loop do
|
66
|
-
|
68
|
+
begin
|
69
|
+
work
|
70
|
+
rescue Exception => ex
|
71
|
+
puts "WORKER UNEXPECTED CRASH: #{ex.message}", lines: ex.backtrace
|
72
|
+
sleep 1
|
73
|
+
end
|
67
74
|
end
|
68
75
|
|
76
|
+
# We should never get here
|
69
77
|
end
|
70
78
|
end
|
71
79
|
|
@@ -102,7 +110,7 @@ module RestFtpDaemon
|
|
102
110
|
sleep 1
|
103
111
|
|
104
112
|
rescue Exception => ex
|
105
|
-
info "
|
113
|
+
info "UNHDNALED EXCEPTION: #{ex.message}", lines: ex.backtrace
|
106
114
|
worker_status :crashed
|
107
115
|
job.oops_after_crash ex unless job.nil?
|
108
116
|
sleep 1
|
@@ -136,5 +144,10 @@ module RestFtpDaemon
|
|
136
144
|
Thread.current.thread_variable_set :updted_at, Time.now
|
137
145
|
end
|
138
146
|
|
147
|
+
if Settings.newrelic_enabled?
|
148
|
+
add_transaction_tracer :create_worker_thread, :category => :task
|
149
|
+
add_transaction_tracer :work, :category => :task
|
150
|
+
end
|
151
|
+
|
139
152
|
end
|
140
153
|
end
|
data/lib/rest-ftp-daemon.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Global libs
|
2
2
|
require 'rubygems'
|
3
|
+
require "settingslogic"
|
3
4
|
require 'json'
|
4
5
|
require 'grape'
|
5
6
|
require 'grape-entity'
|
@@ -14,6 +15,8 @@ require 'net/ftp'
|
|
14
15
|
require 'net/http'
|
15
16
|
require 'double_bag_ftps'
|
16
17
|
|
18
|
+
require 'newrelic_rpm'
|
19
|
+
require 'get_process_mem'
|
17
20
|
|
18
21
|
# Project's libs
|
19
22
|
require 'rest-ftp-daemon/constants'
|
data/rest-ftp-daemon.gemspec
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
# Libs
|
4
|
+
require "settingslogic"
|
4
5
|
app_root = File.dirname(__FILE__)
|
5
6
|
require File.expand_path("#{app_root}/lib/rest-ftp-daemon/constants")
|
6
7
|
|
@@ -36,4 +37,7 @@ Gem::Specification.new do |spec|
|
|
36
37
|
spec.add_runtime_dependency "facter"
|
37
38
|
spec.add_runtime_dependency "sys-cpu"
|
38
39
|
spec.add_runtime_dependency "timeout"
|
40
|
+
spec.add_runtime_dependency "get_process_mem"
|
41
|
+
|
42
|
+
spec.add_runtime_dependency "newrelic_rpm"
|
39
43
|
end
|
data/rest-ftp-daemon.yml.sample
CHANGED
@@ -15,12 +15,15 @@ defaults: &defaults
|
|
15
15
|
overwrite: false
|
16
16
|
timeout: 1800
|
17
17
|
|
18
|
+
# newrelic:
|
19
|
+
# appname: rftpd-testing
|
20
|
+
# license: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
18
21
|
|
19
22
|
conchita:
|
20
23
|
timer: 10
|
21
|
-
#clean_failed: 3600
|
22
|
-
#clean_finished: 3600
|
23
|
-
#clean_queued: 86400
|
24
|
+
# clean_failed: 3600
|
25
|
+
# clean_finished: 3600
|
26
|
+
# clean_queued: 86400
|
24
27
|
|
25
28
|
debug:
|
26
29
|
ftp: false
|
@@ -32,6 +35,7 @@ defaults: &defaults
|
|
32
35
|
workers: "/var/log/rftpd-environment-work.log"
|
33
36
|
jobs: "/var/log/rftpd-environment-work.log"
|
34
37
|
notify: "/var/log/rftpd-environment-work.log"
|
38
|
+
newrelic:"/var/log/rftpd-environment-newrelic.log"
|
35
39
|
|
36
40
|
preprod:
|
37
41
|
<<: *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.212.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno MEDICI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -178,6 +178,34 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: get_process_mem
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: newrelic_rpm
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
181
209
|
description: This is a pretty simple FTP client daemon, controlled through a RESTful
|
182
210
|
API
|
183
211
|
email: rest-ftp-daemon@bmconseil.com
|