rest-ftp-daemon 0.423.3 → 0.424.0

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +30 -0
  3. data/Gemfile.lock +9 -8
  4. data/README.md +1 -5
  5. data/bin/rest-ftp-daemon +11 -5
  6. data/defaults.yml +16 -10
  7. data/lib/rest-ftp-daemon.rb +14 -10
  8. data/lib/rest-ftp-daemon/api/jobs.rb +42 -18
  9. data/lib/rest-ftp-daemon/api/root.rb +5 -1
  10. data/lib/rest-ftp-daemon/constants.rb +0 -1
  11. data/lib/rest-ftp-daemon/{api/entities → entities}/job.rb +0 -0
  12. data/lib/rest-ftp-daemon/{api/entities → entities}/location.rb +0 -0
  13. data/lib/rest-ftp-daemon/{api/entities → entities}/options.rb +0 -0
  14. data/lib/rest-ftp-daemon/exceptions.rb +1 -0
  15. data/lib/rest-ftp-daemon/helpers/views.rb +7 -2
  16. data/lib/rest-ftp-daemon/initialize.rb +3 -0
  17. data/lib/rest-ftp-daemon/job.rb +3 -0
  18. data/lib/rest-ftp-daemon/jobs/transfer.rb +4 -4
  19. data/lib/rest-ftp-daemon/location.rb +5 -0
  20. data/lib/rest-ftp-daemon/remote/base.rb +76 -0
  21. data/lib/rest-ftp-daemon/remote/ftp.rb +144 -0
  22. data/lib/rest-ftp-daemon/remote/s3.rb +78 -0
  23. data/lib/rest-ftp-daemon/remote/sftp.rb +147 -0
  24. data/lib/rest-ftp-daemon/static/images/feature_reload.png +0 -0
  25. data/lib/rest-ftp-daemon/static/images/feature_rollbar.png +0 -0
  26. data/lib/rest-ftp-daemon/static/swagger/css/print.css +2 -2
  27. data/lib/rest-ftp-daemon/static/swagger/css/screen.css +2 -2
  28. data/lib/rest-ftp-daemon/views/dashboard_footer.haml +3 -2
  29. data/lib/rest-ftp-daemon/views/dashboard_jobs.haml +3 -3
  30. data/lib/rest-ftp-daemon/views/dashboard_table.haml +5 -4
  31. data/lib/rest-ftp-daemon/workers/reporter.rb +2 -2
  32. data/rest-ftp-daemon.gemspec +4 -7
  33. metadata +28 -25
  34. data/lib/rest-ftp-daemon/remote.rb +0 -74
  35. data/lib/rest-ftp-daemon/remote_ftp.rb +0 -142
  36. data/lib/rest-ftp-daemon/remote_s3.rb +0 -76
  37. data/lib/rest-ftp-daemon/remote_sftp.rb +0 -145
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2802c64bdd28d6bd4e0101b91bc66899c0e4b3c
4
- data.tar.gz: a1c767f0d1238a66424626d2923711dab7ba78e4
3
+ metadata.gz: 2d4d6f823c82eb53007aceccb525111fce662019
4
+ data.tar.gz: b779d0afa8de9f3f4cf3e935574223f24883e331
5
5
  SHA512:
6
- metadata.gz: f995227ffb577e2b80946cdbbd3c0fa27b275ee855daada08502e0ee39c471a12a62c98ac3cf77afcb5ed07d8313dede12f29a6a7a6d66f8742041a14b10e64d
7
- data.tar.gz: 8307a7e971a9a24bc40f59a257258ef9b700131918170cb208129a42e626eb9e3969b3e6a796224ec5809dccc2391719694eedb49550badc44212bdf3b6c0a0d
6
+ metadata.gz: 67fafa5d1998d4d1a7f9b28fdbfb20b6637e2f506eea4799a277caf3d326133d1e56a554991de05329fc44875268e5a6fb43283ec92c595bb50b98de205b166c
7
+ data.tar.gz: d0dbc285d27a26120887795803c35f250f415ecc1b9d8fd8a1937be313c1767f4b18d31e987a82c944c7374ea21f67cc218f01b7198c74edf344fc4cd3e60b03
data/.codeclimate.yml ADDED
@@ -0,0 +1,30 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+ #checks:
5
+ # Rubocop/Metrics/ClassLength:
6
+ # enabled: false
7
+ brakeman:
8
+ enabled: true
9
+ #exclude_fingerprints:
10
+ #- 08c185b3f764f262539a1f76997d3a89
11
+ eslint:
12
+ enabled: true
13
+ csslint:
14
+ enabled: true
15
+ duplication:
16
+ enabled: true
17
+ config:
18
+ languages:
19
+ - ruby
20
+ #mass_threshold: 30
21
+ - javascript
22
+ ratings:
23
+ paths:
24
+ - app/**
25
+ - lib/**
26
+ - "**.rb"
27
+ - "**.go"
28
+ exclude_paths:
29
+ - spec/**/*
30
+ - "**/swagger/**/*"
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rest-ftp-daemon (0.423.3)
4
+ rest-ftp-daemon (0.424.0)
5
5
  activesupport (~> 4.2)
6
6
  api-auth
7
7
  aws-sdk-resources (~> 2)
8
- bmc-daemon-lib (~> 0.3.4)
8
+ bmc-daemon-lib (~> 0.3.8)
9
9
  double-bag-ftps
10
10
  facter
11
11
  get_process_mem
@@ -19,7 +19,7 @@ PATH
19
19
  net-sftp
20
20
  newrelic_rpm
21
21
  rest-client (~> 1.8)
22
- settingslogic
22
+ rollbar
23
23
  streamio-ffmpeg
24
24
  sys-cpu
25
25
  thin (~> 1.7)
@@ -39,15 +39,15 @@ GEM
39
39
  ast (2.3.0)
40
40
  astrolabe (1.3.1)
41
41
  parser (~> 2.2)
42
- aws-sdk-core (2.5.8)
42
+ aws-sdk-core (2.5.10)
43
43
  jmespath (~> 1.0)
44
- aws-sdk-resources (2.5.8)
45
- aws-sdk-core (= 2.5.8)
44
+ aws-sdk-resources (2.5.10)
45
+ aws-sdk-core (= 2.5.10)
46
46
  axiom-types (0.1.1)
47
47
  descendants_tracker (~> 0.0.4)
48
48
  ice_nine (~> 0.11.0)
49
49
  thread_safe (~> 0.3, >= 0.3.1)
50
- bmc-daemon-lib (0.3.4)
50
+ bmc-daemon-lib (0.3.8)
51
51
  chamber (~> 2.9)
52
52
  builder (3.2.2)
53
53
  chamber (2.9.1)
@@ -140,6 +140,8 @@ GEM
140
140
  http-cookie (>= 1.0.2, < 2.0)
141
141
  mime-types (>= 1.16, < 3.0)
142
142
  netrc (~> 0.7)
143
+ rollbar (2.12.0)
144
+ multi_json
143
145
  rspec (3.5.0)
144
146
  rspec-core (~> 3.5.0)
145
147
  rspec-expectations (~> 3.5.0)
@@ -160,7 +162,6 @@ GEM
160
162
  rainbow (>= 1.99.1, < 3.0)
161
163
  ruby-progressbar (~> 1.4)
162
164
  ruby-progressbar (1.8.1)
163
- settingslogic (2.0.9)
164
165
  slop (3.6.0)
165
166
  streamio-ffmpeg (2.1.0)
166
167
  multi_json (~> 1.8)
data/README.md CHANGED
@@ -53,7 +53,7 @@ a while without any glitches at France Télévisions.
53
53
 
54
54
  #### API Documentation
55
55
 
56
- API documentation was [maintained on Apiary](http://docs.restftpdaemon.apiary.io/) and will me migrated to swagger on day or another.
56
+ API documentation is self-hosted on ```/swagger.html```
57
57
 
58
58
  #### Expected features in a short-time range
59
59
 
@@ -279,10 +279,6 @@ logs:
279
279
  TODO for this document
280
280
  ------------------------------------------------------------------------------------
281
281
 
282
- * Update Apiary documentation
283
- * Update Apiary documentation
284
- * Update Apiary documentation
285
- * Update Apiary documentation !
286
282
  * Document /status
287
283
  * Document /routes
288
284
  * Document mkdir and overwrite options
data/bin/rest-ftp-daemon CHANGED
@@ -24,6 +24,7 @@ begin
24
24
  cmd_user = nil
25
25
  cmd_group = nil
26
26
  cmd_daemonize = nil
27
+ cmd_dump = nil
27
28
 
28
29
  # Init Chamber-based configuration from Gemspec
29
30
  Conf.init File.dirname(__FILE__) + "/../"
@@ -31,9 +32,10 @@ begin
31
32
  # Parse options and check compliance
32
33
  parser = OptionParser.new do |opts|
33
34
  opts.banner = "Usage: #{File.basename $PROGRAM_NAME} [options] start|stop"
34
- opts.on("-c", "--config CONFIGFILE") { |value| cmd_config = File.expand_path(value.to_s)}
35
- opts.on("-e", "--environment ENV") { |value| Conf.app_env = value }
36
- opts.on("", "--dev") { Conf.app_env = "development" }
35
+ opts.on("-c", "--config CONFIGFILE") { |value| cmd_config = File.expand_path(value.to_s)}
36
+ opts.on("", "--dump", "Dump config as seen by the process") { |value| cmd_dump = true }
37
+ opts.on("-e", "--environment ENV") { |value| Conf.app_env = value }
38
+ opts.on("", "--dev") { Conf.app_env = "development" }
37
39
  opts.on("-p", "--port PORT", "use PORT") { |value| cmd_port = value.to_i }
38
40
  opts.on("-d", "--daemonize", "Run daemonized in the background") { cmd_daemonize = true }
39
41
  opts.on("-f", "--foreground", "Run in the foreground") { cmd_daemonize = false }
@@ -120,10 +122,14 @@ puts
120
122
  puts "Daemonize \t #{Conf[:daemonize]}"
121
123
  puts "Network port \t #{Conf[:port]}"
122
124
  puts "User:group \t #{Conf[:user]}:#{Conf[:group]}" if Conf[:user] && Conf[:group]
123
- puts "Newrelic \t #{Conf.newrelic_enabled? ? Conf.at(:newrelic, :license) : 'no'}"
124
125
  puts "PID file \t #{Conf[:pidfile]}"
125
126
  puts
126
- puts Conf.dump
127
+ puts "Newrelic \t #{Conf.feature?(:newrelic) || '-'}"
128
+ puts "Rollbar \t #{Conf.feature?(:rollbar) || '-'}"
129
+ if cmd_dump
130
+ puts
131
+ puts Conf.dump
132
+ end
127
133
  puts
128
134
  puts "--- Thin ARGV"
129
135
  puts argv.flatten.join(" ")
data/defaults.yml CHANGED
@@ -56,18 +56,24 @@ newrelic:
56
56
  prefix: "rftpd" # app prefix to build app_name
57
57
  # platform: "bigbusiness" # app platform to build app_name
58
58
 
59
+ rollbar:
60
+ debug: false
61
+ # token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
62
+
59
63
  logs:
60
64
  path: "/tmp/"
65
+ level: debug
61
66
 
62
- default: "rftpd-environment.log"
67
+ thin: "rftpd-thin.log"
68
+ default: "rftpd-core.log"
63
69
 
64
- thin: "rftpd-environment-thin.log"
65
- newrelic: "rftpd-environment-newrelic.log"
66
- queue: "rftpd-environment-core.log"
67
- api: "rftpd-environment-core.log"
68
- workers: "rftpd-environment-core.log"
70
+ queue: "rftpd-core.log"
71
+ api: "rftpd-core.log"
72
+ workers: "rftpd-core.log"
73
+ transfer: "rftpd-workers.log"
74
+ conchita: "rftpd-workers.log"
75
+ reporter: "rftpd-workers.log"
76
+ notify: "rftpd-workers.log"
69
77
 
70
- transfer: "rftpd-environment-workers.log"
71
- conchita: "rftpd-environment-workers.log"
72
- reporter: "rftpd-environment-workers.log"
73
- notify: "rftpd-environment-workers.log"
78
+ newrelic: "rftpd-newrelic.log"
79
+ rollbar: "rftpd-rollbar.log"
@@ -8,6 +8,7 @@ require "timeout"
8
8
  require "syslog"
9
9
  require "thread"
10
10
  require "newrelic_rpm"
11
+ require "rollbar"
11
12
 
12
13
  # Shared libs / monkey-patching
13
14
  require_relative "shared/patch_array"
@@ -28,10 +29,10 @@ require_relative "rest-ftp-daemon/notification"
28
29
  require_relative "rest-ftp-daemon/location"
29
30
 
30
31
  # Remotes
31
- require_relative "rest-ftp-daemon/remote"
32
- require_relative "rest-ftp-daemon/remote_ftp"
33
- require_relative "rest-ftp-daemon/remote_sftp"
34
- require_relative "rest-ftp-daemon/remote_s3"
32
+ require_relative "rest-ftp-daemon/remote/base"
33
+ require_relative "rest-ftp-daemon/remote/ftp"
34
+ require_relative "rest-ftp-daemon/remote/sftp"
35
+ require_relative "rest-ftp-daemon/remote/s3"
35
36
 
36
37
  # Jobs
37
38
  require_relative "rest-ftp-daemon/job"
@@ -40,19 +41,18 @@ require_relative "rest-ftp-daemon/jobs/dummy"
40
41
  require_relative "rest-ftp-daemon/jobs/transfer"
41
42
  require_relative "rest-ftp-daemon/jobs/video"
42
43
 
43
- require_relative "rest-ftp-daemon/worker_pool"
44
-
45
44
  # Workers
46
45
  # require_from :workers
46
+ require_relative "rest-ftp-daemon/worker_pool"
47
47
  require_relative "rest-ftp-daemon/workers/worker"
48
48
  require_relative "rest-ftp-daemon/workers/conchita"
49
49
  require_relative "rest-ftp-daemon/workers/reporter"
50
50
  require_relative "rest-ftp-daemon/workers/transfer"
51
51
 
52
- # API
53
- require_relative "rest-ftp-daemon/api/entities/location"
54
- require_relative "rest-ftp-daemon/api/entities/options"
55
- require_relative "rest-ftp-daemon/api/entities/job"
52
+ # Entities and API
53
+ require_relative "rest-ftp-daemon/entities/location"
54
+ require_relative "rest-ftp-daemon/entities/options"
55
+ require_relative "rest-ftp-daemon/entities/job"
56
56
  require_relative "rest-ftp-daemon/api/jobs"
57
57
  require_relative "rest-ftp-daemon/api/dashboard"
58
58
  require_relative "rest-ftp-daemon/api/status"
@@ -60,6 +60,10 @@ require_relative "rest-ftp-daemon/api/config"
60
60
  require_relative "rest-ftp-daemon/api/debug"
61
61
  require_relative "rest-ftp-daemon/api/root"
62
62
 
63
+ # Init
64
+ require_relative "rest-ftp-daemon/initialize"
65
+
66
+
63
67
  # def require_from subdir
64
68
  # path = sprintf(
65
69
  # '%s/rest-ftp-daemon/%s/*.rb',
@@ -59,12 +59,30 @@ module RestFtpDaemon
59
59
  end
60
60
 
61
61
  desc "Create a new job"
62
- params do
63
- requires :source, type: String, desc: "Source file pattern"
64
- requires :target, type: String, desc: "Target remote path"
62
+ # desc 'Creates a new app' do
63
+ # detail 'It is used to register a new app on the server and get the app_id'
64
+ # params Entities::AppsParamsEntity.documentation
65
+ # success Entities::AppsEntity
66
+ # failure [[400, 'Bad Request', Entities::ErrorEntity]]
67
+ # named 'create app'
68
+ # end
65
69
 
66
- optional :label, type: String, desc: "Descriptive label (info only)"
67
- optional :notify, type: String, desc: "URL to get POST'ed notifications back"
70
+ params do
71
+ requires :source,
72
+ type: String,
73
+ desc: "Source file pattern",
74
+ allow_blank: false
75
+ requires :target,
76
+ type: String,
77
+ desc: "Target remote path",
78
+ allow_blank: false
79
+ optional :label,
80
+ type: String,
81
+ desc: "Descriptive label (info only)"
82
+ optional :notify,
83
+ type: String,
84
+ desc: "URL to get POST'ed notifications back",
85
+ allow_blank: false
68
86
  optional :type,
69
87
  type: String,
70
88
  desc: "Type of job",
@@ -81,19 +99,19 @@ module RestFtpDaemon
81
99
  default: 0
82
100
 
83
101
  optional :video_options, type: Hash, desc: "Options passed to FFMPEG encoder", default: {} do
84
- optional :video_codec, type: String
85
- optional :video_bitrate, type: String
86
- optional :video_bitrate_tolerance, type: String
87
- optional :frame_rate, type: Integer
88
- optional :resolution, type: String
89
- optional :aspect, type: String
90
- optional :keyframe_interval, type: String
91
- optional :x264_vprofile, type: String
92
- optional :x264_preset, type: String
93
- optional :audio_codec, type: String
94
- optional :audio_bitrate, type: String
95
- optional :audio_sample_rate, type: Integer
96
- optional :audio_channels, type: String
102
+ optional :video_codec, type: String, desc: "video codec (ex: copy, libx264)"
103
+ optional :video_bitrate, type: String, desc: "nominal video bitrate"
104
+ optional :video_bitrate_tolerance, type: String, desc: "maximum video bitrate"
105
+ optional :frame_rate, type: Integer, desc: "output frames per second"
106
+ optional :resolution, type: String, desc: "output video resolution"
107
+ optional :aspect, type: String, desc: "output aspect ratio"
108
+ optional :keyframe_interval, type: String, desc: "group of pictures (GOP) size"
109
+ optional :x264_vprofile, type: String, desc: "h264 profile"
110
+ optional :x264_preset, type: String, desc: "h264 preset (fast, low..)"
111
+ optional :audio_codec, type: String, desc: "audio codec (ex: copy, libfaac, ibfdk_aac)"
112
+ optional :audio_bitrate, type: String, desc: "nominal audio bitrate"
113
+ optional :audio_sample_rate, type: Integer, desc: "audio sampling rate"
114
+ optional :audio_channels, type: String, desc: "number of audio channels"
97
115
  end
98
116
 
99
117
  optional :video_custom,
@@ -113,6 +131,12 @@ module RestFtpDaemon
113
131
  type: Boolean,
114
132
  desc: "Upload to a temp file before renaming it to the target filename",
115
133
  default: Conf.at(:transfer, :tempfile)
134
+ # given :shelf_id do
135
+ # requires :bin_id, type: Integer
136
+ # end
137
+ # given category: ->(val) { val == 'foo' } do
138
+ # requires :description
139
+ # end
116
140
  end
117
141
 
118
142
  post "/" do
@@ -50,6 +50,11 @@ module RestFtpDaemon
50
50
  put "-----"
51
51
  end
52
52
 
53
+ ## GLOBAL EXCEPTION HANDLING
54
+ rescue_from :all do |exception|
55
+ Rollbar.error exception
56
+ error_response(message: "Internal server error: #{exception}", status: 500)
57
+ end
53
58
 
54
59
  ### MOUNTPOINTS
55
60
  mount RestFtpDaemon::API::Status => MOUNT_STATUS
@@ -71,7 +76,6 @@ module RestFtpDaemon
71
76
  }
72
77
 
73
78
 
74
-
75
79
  ### INITIALIZATION
76
80
  def initialize
77
81
  super
@@ -20,7 +20,6 @@ INFO_PROGRESS = :work_progress
20
20
  INFO_BITRATE = :transfer_bitrate
21
21
 
22
22
  # Constants: logger
23
- LOG_ROTATION = "daily"
24
23
  LOG_FORMAT_PROGNAME = "%d\t%s"
25
24
  LOG_HEADER_TIME = "%Y-%m-%d %H:%M:%S"
26
25
  LOG_HEADER_FORMAT = "%s \t%d\t%-8s %-10s "
@@ -15,6 +15,7 @@ module RestFtpDaemon
15
15
  class AttributeMissing < RestFtpDaemonException; end
16
16
  class AssertionFailed < RestFtpDaemonException; end
17
17
  class UnresolvedTokens < RestFtpDaemonException; end
18
+ class LocationMalformed < RestFtpDaemonException; end
18
19
  class LocationParseError < RestFtpDaemonException; end
19
20
  class UnsupportedScheme < RestFtpDaemonException; end
20
21
  class MissingFfmpegLibraries < RestFtpDaemonException; end
@@ -68,10 +68,15 @@ module RestFtpDaemon
68
68
  end
69
69
 
70
70
  def job_type job
71
+ # sprintf(
72
+ # '<span class="glyphicon glyphicon-%s" alt="%s"></span>&nbsp;%s',
73
+ # job_style(job),
74
+ # job.type,
75
+ # job.type
76
+ # )
71
77
  sprintf(
72
- '<span class="glyphicon glyphicon-%s" alt="%s"></span>&nbsp;%s',
78
+ '<span class="glyphicon glyphicon-%s" alt="%s"></span>',
73
79
  job_style(job),
74
- job.type,
75
80
  job.type
76
81
  )
77
82
  end
@@ -0,0 +1,3 @@
1
+ # Init Rollbar and Newrelic
2
+ Conf.prepare_newrelic
3
+ Conf.prepare_rollbar
@@ -303,6 +303,9 @@ module RestFtpDaemon
303
303
  log_error message
304
304
  end
305
305
 
306
+ # Log to Rollbar
307
+ Rollbar.error(exception)
308
+
306
309
  # Close ftp connexion if open
307
310
  @remote.close unless @remote.nil? || !@remote.connected?
308
311
 
@@ -22,16 +22,16 @@ module RestFtpDaemon
22
22
  case target_uri
23
23
  when URI::FTP
24
24
  log_info "JobTransfer.before target_method FTP"
25
- @remote = RemoteFTP.new @target_loc, log_prefix, @config[:debug_ftp]
25
+ @remote = Remote::RemoteFTP.new @target_loc, log_prefix, @config[:debug_ftp]
26
26
  when URI::FTPES, URI::FTPS
27
27
  log_info "JobTransfer.before target_method FTPES/FTPS"
28
- @remote = RemoteFTP.new @target_loc, log_prefix, @config[:debug_ftps], :ftpes
28
+ @remote = Remote::RemoteFTP.new @target_loc, log_prefix, @config[:debug_ftps], :ftpes
29
29
  when URI::SFTP
30
30
  log_info "JobTransfer.before target_method SFTP"
31
- @remote = RemoteSFTP.new @target_loc, log_prefix, @config[:debug_sftp]
31
+ @remote = Remote::RemoteSFTP.new @target_loc, log_prefix, @config[:debug_sftp]
32
32
  when URI::S3
33
33
  log_info "JobTransfer.before target_method S3"
34
- @remote = RemoteS3.new @target_loc, log_prefix, @config[:debug_s3]
34
+ @remote = Remote::RemoteS3.new @target_loc, log_prefix, @config[:debug_s3]
35
35
  else
36
36
  log_info "JobTransfer.before unknown scheme [#{@target_loc.scheme}]"
37
37
  raise RestFtpDaemon::TargetNotSupported, @target_loc.scheme
@@ -27,6 +27,10 @@ module RestFtpDaemon
27
27
  to: :uri
28
28
 
29
29
  def initialize original
30
+ unless original.is_a? String
31
+ raise RestFtpDaemon::LocationMalformed, original.inspect
32
+ end
33
+
30
34
  # Strip spaces before/after, copying original "path" at the same time
31
35
  @original = original
32
36
  location_uri = original.strip
@@ -102,6 +106,7 @@ module RestFtpDaemon
102
106
 
103
107
  # Replace endpoints defined in config
104
108
  vectors.each do |from, to|
109
+ next unless to.is_a? String
105
110
  next if to.to_s.empty?
106
111
  path.gsub! tokenize(from), to
107
112
  end