rest-ftp-daemon 0.245 → 0.245.1
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/Gemfile.lock +1 -1
- data/README.md +10 -2
- data/bin/rest-ftp-daemon +0 -1
- data/lib/rest-ftp-daemon/constants.rb +31 -32
- data/lib/rest-ftp-daemon/job.rb +32 -32
- data/lib/rest-ftp-daemon/worker_job.rb +2 -0
- data/rest-ftp-daemon.yml.sample +14 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 543ad77656660d81d07cf854694e58db9c31fb3b
|
4
|
+
data.tar.gz: 8562831e868f6215c41d58096f593d49265887d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06381f06990e68bfe3a1c4091291c91bb0fed0f3e98e12b60123b11e3b529c2406c301c4a3f450d5121447a7bde0d6a2a7763338323a453eff23d0396f50fd0c
|
7
|
+
data.tar.gz: 962fba554f02dcb527fbfe9d27cf369bcd196feb374a27a4df872063a3f93bc5517bf81d6caedc2dd0cf7c20d00ca702392e480fb6ba8aa45be9075d3adaad02
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Features
|
|
21
21
|
* environment-aware configuration in a YAML file
|
22
22
|
* daemon process is tagged with its name and environment in process lists
|
23
23
|
* global dashboard directly served within the daemon HTTP interface
|
24
|
-
|
24
|
+
* support pooling of worker to separate capacity among jobs
|
25
25
|
|
26
26
|
* File management ans transferts
|
27
27
|
* allow authentication in FTP target in a standard URI-format
|
@@ -97,7 +97,6 @@ Launcher options :
|
|
97
97
|
| -p | --port | (automatic) | Port to listen for API requests |
|
98
98
|
| -e | | production | Environment name |
|
99
99
|
| | --dev | | Equivalent to -e development |
|
100
|
-
| -w | --workers | 1 | Number of workers spawned at launch |
|
101
100
|
| -d | --daemonize | false | Wether to send the daemon to background |
|
102
101
|
| -f | --foreground | false | Wether to keep the daemon running in the shell |
|
103
102
|
| -P | --pid | (automatic) | Path of the file containing the PID |
|
@@ -140,6 +139,15 @@ curl -H "Content-Type: application/json" -X POST -D /dev/stdout -d \
|
|
140
139
|
```
|
141
140
|
|
142
141
|
|
142
|
+
#### Start a job with a specific pool name
|
143
|
+
|
144
|
+
```
|
145
|
+
curl -H "Content-Type: application/json" -X POST -D /dev/stdout -d \
|
146
|
+
'{"pool": "maxxxxx",source":"~/file.iso",target":"ftp://anonymous@localhost/incoming/dest2.iso"}' "http://localhost:3000/jobs"
|
147
|
+
```
|
148
|
+
This job will be handled by the "maxxxxx" workers only, or by the default worker is this pool is not declared.
|
149
|
+
|
150
|
+
|
143
151
|
#### Get info about a job with ID="q89j.1"
|
144
152
|
|
145
153
|
Both parameters `q89j.1` and `1` will be accepted as ID in the API. Requests below are equivalent:
|
data/bin/rest-ftp-daemon
CHANGED
@@ -28,7 +28,6 @@ parser = OptionParser.new do |opts|
|
|
28
28
|
opts.on("-e", "--environment ENV") { |env| APP_ENV = env }
|
29
29
|
opts.on("", "--dev") { APP_ENV = "development" }
|
30
30
|
opts.on("-p", "--port PORT", "use PORT") { |port| options["port"] = port.to_i }
|
31
|
-
opts.on("-w", "--workers COUNT", "Use COUNT worker threads") { |count| options["workers"] = count.to_i }
|
32
31
|
opts.on("-d", "--daemonize", "Run daemonized in the background") { options["daemonize"] = true }
|
33
32
|
opts.on("-f", "--foreground", "Run in the foreground") { options["daemonize"] = false }
|
34
33
|
opts.on("-P", "--pid FILE", "File to store PID") { |file| options["pidfile"] = file }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Terrific constants
|
2
2
|
APP_NAME = "rest-ftp-daemon"
|
3
3
|
APP_NICK = "rftpd"
|
4
|
-
APP_VER = "0.245"
|
4
|
+
APP_VER = "0.245.1"
|
5
5
|
|
6
6
|
# Provide default config file information
|
7
7
|
APP_LIB = File.expand_path File.dirname(__FILE__)
|
@@ -22,7 +22,7 @@ EOD
|
|
22
22
|
# Configuration defaults
|
23
23
|
# DEFAULT_WORKERS = 2
|
24
24
|
DEFAULT_POOL = "default"
|
25
|
-
DEFAULT_WORKER_TIMEOUT =
|
25
|
+
DEFAULT_WORKER_TIMEOUT = 1800 # 1h
|
26
26
|
DEFAULT_SFTP_TIMEOUT = 600 # 10mn
|
27
27
|
DEFAULT_FTP_CHUNK = 1024 # 1 MB
|
28
28
|
DEFAULT_PAGE_SIZE = 50 # 50 lines
|
@@ -37,26 +37,26 @@ JOB_UPDATE_INTERVAL = 1
|
|
37
37
|
|
38
38
|
|
39
39
|
# Jobs and workers statuses
|
40
|
-
JOB_STATUS_PREPARING =
|
41
|
-
JOB_STATUS_RUNNING =
|
42
|
-
JOB_STATUS_CHECKING_SRC =
|
43
|
-
JOB_STATUS_CONNECTING =
|
44
|
-
JOB_STATUS_CHDIR =
|
45
|
-
JOB_STATUS_UPLOADING =
|
46
|
-
JOB_STATUS_RENAMING =
|
47
|
-
JOB_STATUS_PREPARED =
|
48
|
-
JOB_STATUS_DISCONNECTING=
|
49
|
-
JOB_STATUS_FINISHED =
|
50
|
-
JOB_STATUS_FAILED =
|
51
|
-
JOB_STATUS_QUEUED =
|
52
|
-
|
53
|
-
WORKER_STATUS_STARTING =
|
54
|
-
WORKER_STATUS_WAITING =
|
55
|
-
WORKER_STATUS_RUNNING =
|
56
|
-
WORKER_STATUS_FINISHED =
|
57
|
-
WORKER_STATUS_TIMEOUT =
|
58
|
-
WORKER_STATUS_CRASHED =
|
59
|
-
WORKER_STATUS_CLEANING =
|
40
|
+
JOB_STATUS_PREPARING = "preparing"
|
41
|
+
JOB_STATUS_RUNNING = "running"
|
42
|
+
JOB_STATUS_CHECKING_SRC = "checking_source"
|
43
|
+
JOB_STATUS_CONNECTING = "remote_connect"
|
44
|
+
JOB_STATUS_CHDIR = "remote_chdir"
|
45
|
+
JOB_STATUS_UPLOADING = "uploading"
|
46
|
+
JOB_STATUS_RENAMING = "renaming"
|
47
|
+
JOB_STATUS_PREPARED = "prepared"
|
48
|
+
JOB_STATUS_DISCONNECTING= "remote_disconnect"
|
49
|
+
JOB_STATUS_FINISHED = "finished"
|
50
|
+
JOB_STATUS_FAILED = "failed"
|
51
|
+
JOB_STATUS_QUEUED = "queued"
|
52
|
+
|
53
|
+
WORKER_STATUS_STARTING = "starting"
|
54
|
+
WORKER_STATUS_WAITING = "waiting"
|
55
|
+
WORKER_STATUS_RUNNING = "running"
|
56
|
+
WORKER_STATUS_FINISHED = "finished"
|
57
|
+
WORKER_STATUS_TIMEOUT = "timeout"
|
58
|
+
WORKER_STATUS_CRASHED = "crashed"
|
59
|
+
WORKER_STATUS_CLEANING = "cleaning"
|
60
60
|
|
61
61
|
|
62
62
|
# Logging and startup
|
@@ -84,18 +84,17 @@ NOTIFY_IDENTIFIER_LEN = 4
|
|
84
84
|
|
85
85
|
# Dashboard row styles
|
86
86
|
DASHBOARD_JOB_STYLES = {
|
87
|
-
JOB_STATUS_QUEUED
|
88
|
-
JOB_STATUS_FAILED
|
89
|
-
JOB_STATUS_FINISHED
|
90
|
-
JOB_STATUS_UPLOADING
|
91
|
-
JOB_STATUS_RENAMING
|
87
|
+
JOB_STATUS_QUEUED => :active,
|
88
|
+
JOB_STATUS_FAILED => :warning,
|
89
|
+
JOB_STATUS_FINISHED => :success,
|
90
|
+
JOB_STATUS_UPLOADING => :info,
|
91
|
+
JOB_STATUS_RENAMING => :info,
|
92
92
|
}
|
93
93
|
DASHBOARD_WORKER_STYLES = {
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
dead: :danger,
|
94
|
+
WORKER_STATUS_WAITING => :success,
|
95
|
+
WORKER_STATUS_RUNNING => :info,
|
96
|
+
WORKER_STATUS_CRASHED => :danger,
|
97
|
+
WORKER_STATUS_FINISHED => :success,
|
99
98
|
}
|
100
99
|
|
101
100
|
|
data/lib/rest-ftp-daemon/job.rb
CHANGED
@@ -104,22 +104,22 @@ module RestFtpDaemon
|
|
104
104
|
prepare
|
105
105
|
|
106
106
|
rescue RestFtpDaemon::JobMissingAttribute => exception
|
107
|
-
return oops :started, exception,
|
107
|
+
return oops :started, exception, "missing_attribute"
|
108
108
|
|
109
109
|
rescue RestFtpDaemon::JobUnresolvedTokens => exception
|
110
|
-
return oops :started, exception,
|
110
|
+
return oops :started, exception, "unresolved_tokens"
|
111
111
|
|
112
112
|
rescue RestFtpDaemon::JobTargetUnparseable => exception
|
113
|
-
return oops :started, exception,
|
113
|
+
return oops :started, exception, "target_unparseable"
|
114
114
|
|
115
115
|
rescue RestFtpDaemon::JobTargetUnsupported => exception
|
116
|
-
return oops :started, exception,
|
116
|
+
return oops :started, exception, "target_unsupported"
|
117
117
|
|
118
118
|
rescue RestFtpDaemon::JobAssertionFailed => exception
|
119
|
-
return oops :started, exception,
|
119
|
+
return oops :started, exception, "assertion_failed"
|
120
120
|
|
121
121
|
rescue URI::InvalidURIError => exception
|
122
|
-
return oops :started, exception,
|
122
|
+
return oops :started, exception, "target_invalid"
|
123
123
|
|
124
124
|
else
|
125
125
|
# Prepare done !
|
@@ -130,77 +130,77 @@ module RestFtpDaemon
|
|
130
130
|
|
131
131
|
# Process job
|
132
132
|
begin
|
133
|
-
#
|
133
|
+
#return oops :ended, Exception.new, "ftp_perm_error"
|
134
134
|
run
|
135
135
|
|
136
136
|
rescue SocketError => exception
|
137
|
-
return oops :ended, exception,
|
137
|
+
return oops :ended, exception, "conn_socket_error"
|
138
138
|
|
139
139
|
rescue EOFError => exception
|
140
|
-
return oops :ended, exception,
|
140
|
+
return oops :ended, exception, "conn_eof"
|
141
141
|
|
142
142
|
rescue Errno::EHOSTDOWN => exception
|
143
|
-
return oops :ended, exception,
|
143
|
+
return oops :ended, exception, "conn_host_is_down"
|
144
144
|
|
145
145
|
rescue Errno::ENETUNREACH => exception
|
146
|
-
return oops :ended, exception,
|
146
|
+
return oops :ended, exception, "conn_unreachable"
|
147
147
|
|
148
148
|
rescue Errno::ECONNRESET => exception
|
149
|
-
return oops :ended, exception,
|
149
|
+
return oops :ended, exception, "conn_reset_by_peer"
|
150
150
|
|
151
151
|
rescue Errno::ENOTCONN => exception
|
152
|
-
return oops :ended, exception,
|
152
|
+
return oops :ended, exception, "conn_failed"
|
153
153
|
|
154
154
|
rescue Errno::ECONNREFUSED => exception
|
155
|
-
return oops :ended, exception,
|
155
|
+
return oops :ended, exception, "conn_refused"
|
156
156
|
|
157
157
|
rescue Timeout::Error, Errno::ETIMEDOUT, Net::ReadTimeout => exception
|
158
|
-
return oops :ended, exception,
|
158
|
+
return oops :ended, exception, "conn_timed_out"
|
159
159
|
|
160
160
|
rescue OpenSSL::SSL::SSLError => exception
|
161
|
-
return oops :ended, exception,
|
161
|
+
return oops :ended, exception, "conn_openssl_error"
|
162
162
|
|
163
163
|
rescue Net::FTPPermError => exception
|
164
|
-
return oops :ended, exception,
|
164
|
+
return oops :ended, exception, "ftp_perm_error"
|
165
165
|
|
166
166
|
rescue Net::FTPTempError => exception
|
167
|
-
return oops :ended, exception,
|
167
|
+
return oops :ended, exception, "net_temp_error"
|
168
168
|
|
169
169
|
rescue Net::SFTP::StatusException => exception
|
170
|
-
return oops :ended, exception,
|
170
|
+
return oops :ended, exception, "sftp_exception"
|
171
171
|
|
172
172
|
rescue Net::SSH::HostKeyMismatch => exception
|
173
|
-
return oops :ended, exception,
|
173
|
+
return oops :ended, exception, "sftp_key_mismatch"
|
174
174
|
|
175
175
|
rescue Net::SSH::AuthenticationFailed => exception
|
176
|
-
return oops :ended, exception,
|
176
|
+
return oops :ended, exception, "sftp_auth_failed"
|
177
177
|
|
178
178
|
rescue Errno::EMFILE => exception
|
179
|
-
return oops :ended, exception,
|
179
|
+
return oops :ended, exception, "too_many_open_files"
|
180
180
|
|
181
181
|
rescue Errno::EINVAL => exception
|
182
|
-
return oops :ended, exception,
|
182
|
+
return oops :ended, exception, "invalid_argument", true
|
183
183
|
|
184
184
|
rescue Encoding::UndefinedConversionError => exception
|
185
|
-
return oops :ended, exception,
|
185
|
+
return oops :ended, exception, "encoding_error", true
|
186
186
|
|
187
187
|
rescue RestFtpDaemon::JobSourceNotFound => exception
|
188
|
-
return oops :ended, exception,
|
188
|
+
return oops :ended, exception, "source_not_found"
|
189
189
|
|
190
190
|
rescue RestFtpDaemon::JobSourceNotReadable => exception
|
191
|
-
return oops :ended, exception,
|
191
|
+
return oops :ended, exception, "source_not_readable"
|
192
192
|
|
193
193
|
rescue RestFtpDaemon::JobTargetFileExists => exception
|
194
|
-
return oops :ended, exception,
|
194
|
+
return oops :ended, exception, "target_file_exists"
|
195
195
|
|
196
196
|
rescue RestFtpDaemon::JobTargetDirectoryError => exception
|
197
|
-
return oops :ended, exception,
|
197
|
+
return oops :ended, exception, "target_directory_missing"
|
198
198
|
|
199
199
|
rescue RestFtpDaemon::JobTargetPermissionError => exception
|
200
|
-
return oops :ended, exception,
|
200
|
+
return oops :ended, exception, "target_permission_error"
|
201
201
|
|
202
202
|
rescue RestFtpDaemon::JobAssertionFailed => exception
|
203
|
-
return oops :ended, exception,
|
203
|
+
return oops :ended, exception, "assertion_failed"
|
204
204
|
|
205
205
|
else
|
206
206
|
# All done !
|
@@ -231,11 +231,11 @@ module RestFtpDaemon
|
|
231
231
|
end
|
232
232
|
|
233
233
|
def oops_after_crash exception
|
234
|
-
oops :ended, exception,
|
234
|
+
oops :ended, exception, "crashed"
|
235
235
|
end
|
236
236
|
|
237
237
|
def oops_you_stop_now exception
|
238
|
-
oops :ended, exception,
|
238
|
+
oops :ended, exception, "timeout"
|
239
239
|
end
|
240
240
|
|
241
241
|
def age
|
@@ -35,6 +35,8 @@ module RestFtpDaemon
|
|
35
35
|
max_age = Settings.at(:retry, :max_age)
|
36
36
|
max_runs = Settings.at(:retry, :max_runs)
|
37
37
|
delay = Settings.at(:retry, :delay)
|
38
|
+
# log_error "on_errors: #{on_errors.inspect} (#{on_errors.first.class})"
|
39
|
+
# log_error "job.error: #{job.error} (#{job.error.class})"
|
38
40
|
|
39
41
|
if !job.error
|
40
42
|
#log_info "job succeeded"
|
data/rest-ftp-daemon.yml.sample
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
defaults: &defaults
|
2
2
|
daemonize: true
|
3
3
|
port: 3000
|
4
|
-
workers: 2
|
5
4
|
user: rftpd
|
6
5
|
group: rftpd
|
7
6
|
#host: "myhost"
|
8
7
|
|
8
|
+
pools:
|
9
|
+
default: 2
|
10
|
+
|
9
11
|
transfer:
|
10
12
|
# notify_after_sec: 5 # wait at least X seconds between HTTP notifications
|
11
13
|
# mkdir: true # build directory tree if missing
|
@@ -14,7 +16,17 @@ defaults: &defaults
|
|
14
16
|
# timeout: 1800 # jobs running for longer than X seconds will be killed
|
15
17
|
|
16
18
|
retry:
|
17
|
-
# on_errors:
|
19
|
+
# on_errors:
|
20
|
+
# - ftp_perm_error
|
21
|
+
# - net_temp_error
|
22
|
+
# - conn_reset_by_peer
|
23
|
+
# - conn_timed_out
|
24
|
+
# - conn_refused
|
25
|
+
# - sftp_auth_failed
|
26
|
+
# - conn_host_is_down
|
27
|
+
# - conn_unreachable
|
28
|
+
# - conn_failed
|
29
|
+
# - conn_openssl_error
|
18
30
|
# max_runs: 5
|
19
31
|
# max_age: 1800
|
20
32
|
# delay: 10
|