cantemo-portal-agent 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b3f1ea75c5103dd91d6b863538cb5bd4b6ff7c2
4
- data.tar.gz: '0796314e40e182e785a2d8cc8290be0e0a653545'
3
+ metadata.gz: 941c3be4e0b16164d64637173764d3fcaacc01f1
4
+ data.tar.gz: 1531dde6210f28ce51e5c7bdd514c85d03910f3b
5
5
  SHA512:
6
- metadata.gz: a57aeb7f14fceb67dfbbbfe091593c49ef57491fb5968b3f4b46e9a3beccff7964153a8b06d88e13268b10de315102db28a147647a5c9455090c4a7fe46af748
7
- data.tar.gz: 68487f27150376d370b6254df75a339b49385d3957eb490e90e79bc9c3054dc7b77d8e5fe50dae5ad0ee42c9eea71d5fee803306e7378338c18bb6ae00e18083
6
+ metadata.gz: 114af11cb4e03732296cd5d5c39727042bedc457440d7cbd89b5842233004da96c0442a97df73cc8fed297745b3ea2a1a87f9a67539a2ebab7c18c2038cdadbd
7
+ data.tar.gz: ff6261efd8fc22cc8019b7bee7a36fba60f61d22d87202604f39d9dc39a610feb0965500dd5ba5f338ca3f6469651f98373c786ba0278e4e8ef720e1f545c679
@@ -52,12 +52,18 @@ if sub_command == 'help'
52
52
  exit
53
53
  end
54
54
 
55
+
55
56
  config_file_path = args[:config_file_path]
56
57
  if config_file_path.is_a?(Array)
57
58
  args[:config_file_path].map! { |v| File.expand_path(v) }
58
59
  config_file_path = config_file_path.find { |file_path| File.exist?(file_path) }
60
+ else
61
+ args[:config_file_path] = config_file_path = File.expand_path(config_file_path)
59
62
  end
60
63
 
64
+ unless config_file_path && File.exist?(config_file_path)
65
+ abort("Configuration file not found. Path(s): #{args[:config_file_path]}")
66
+ end
61
67
 
62
68
  # daemon_control_command_present = sub_command && begin
63
69
  # sub_command = sub_command.dup.downcase if sub_command
@@ -79,25 +85,10 @@ end
79
85
  module Application
80
86
 
81
87
  module OS
82
- def OS.windows?
83
- (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
84
- end
85
-
86
- def OS.mac?
87
- (/darwin/ =~ RUBY_PLATFORM) != nil
88
- end
89
-
90
- def OS.unix?
91
- !OS.windows?
92
- end
93
-
94
- def OS.linux?
95
- OS.unix? and not OS.mac?
96
- end
97
- end
98
-
99
- class ProcessManager
100
-
88
+ def OS.windows?; (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil end
89
+ def OS.mac?; (/darwin/ =~ RUBY_PLATFORM) != nil end
90
+ def OS.unix?; !OS.windows? end
91
+ def OS.linux?; OS.unix? and not OS.mac? end
101
92
  end
102
93
 
103
94
  if OS.windows?
@@ -109,7 +100,8 @@ module Application
109
100
  end
110
101
 
111
102
  def service_main(*args)
112
- @WatchFolderManager = WATCH_FOLDER_MANAGER_CLASS.run(args)
103
+ @WatchFolderManager = WATCH_FOLDER_MANAGER_CLASS.new(args)
104
+ @WatchFolderManager.run
113
105
  end
114
106
 
115
107
  def service_stop
@@ -117,11 +109,11 @@ module Application
117
109
  end
118
110
 
119
111
  def service_pause
120
-
112
+ @WatchFolderManager.pause
121
113
  end
122
114
 
123
115
  def service_resume
124
-
116
+ @WatchFolderManager.resume
125
117
  end
126
118
 
127
119
  # Watcher - Windows
@@ -176,7 +168,6 @@ module Application
176
168
 
177
169
  def self.run_with_process_manager(args, options = {})
178
170
  # ARGV.unshift 'run' unless %w(start stop restart run zap killall status).include? ARGV.first
179
- self.run(args)
180
171
  require 'daemons'
181
172
  proc = Proc.new { self.run(args) }
182
173
  app_name = APP_NAME
@@ -200,18 +191,26 @@ module Application
200
191
 
201
192
  end
202
193
 
203
- def run_in_foreground(args)
194
+ def self.run_in_foreground(args)
204
195
  Watcher.run(args)
205
196
  end
206
197
 
207
- def run(args)
198
+ def self.run_with_process_manager(args)
199
+ Watcher.run_with_process_manager(args)
200
+ end
201
+
202
+ def self.run(args)
208
203
 
209
204
  end
210
205
 
211
206
  end
212
207
 
208
+ # puts "ARGV: #{ARGV}"
209
+ # exit
210
+
213
211
  if !Application::OS.windows?
214
212
  begin
213
+ ARGV.unshift sub_command unless ARGV.first == sub_command
215
214
  Application.run_with_process_manager(args)
216
215
  exit
217
216
  rescue => e
@@ -219,6 +218,18 @@ if !Application::OS.windows?
219
218
  end
220
219
  end
221
220
 
221
+
222
+ module Application
223
+
224
+ class WindowsDaemon
225
+
226
+ end
227
+
228
+ class WindowsService
229
+
230
+ end
231
+
232
+ end
222
233
  # Options:
223
234
  # install - Installs the service.
224
235
  # start - Starts the service.
@@ -239,11 +250,12 @@ EXECUTABLE_NAME = __FILE__
239
250
 
240
251
  # You must provide at least one argument.
241
252
  abort('No argument provided.') unless sub_command
242
- abort('Service not installed.') unless Service.exists?(SERVICE_NAME) && sub_command == 'install'
253
+ abort('Service not installed.') unless Service.exists?(SERVICE_NAME) || sub_command == 'install'
243
254
 
244
255
 
245
256
  case sub_command
246
257
  when 'runasservice'
258
+ Application::Watcher.mainloop(args)
247
259
  when 'start'
248
260
  if Service.status(SERVICE_NAME).current_state != 'running'
249
261
  Service.start(SERVICE_NAME, nil)
@@ -1,7 +1,7 @@
1
1
  module Cantemo
2
2
  module Portal
3
3
  class Agent
4
- VERSION = '1.3.1'.freeze
4
+ VERSION = '1.3.2'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,19 @@
1
+ module Envoi
2
+
3
+ module Mam
4
+
5
+ class Agent
6
+
7
+ class Daemon
8
+
9
+ class ServiceWrapper
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -344,125 +344,6 @@ module Envoi
344
344
  handler.stable_files
345
345
  end
346
346
 
347
- def process_stable_files
348
- active_processors = @processors_by_watch_folder[wf]
349
- maximum_active_processors = definition['maximum_active_processors']
350
-
351
- includes = definition['includes']
352
- excludes = definition['excludes']
353
-
354
- unless ignored_file_paths
355
- ignored_file_paths = @ignored_file_paths_by_watch_folder[wf]
356
- end
357
-
358
- stable_files.each do |file|
359
- file.watch_folder ||= wf
360
- next if file.respond_to?(:ignore?) ? file.ignore? : ignored_file_paths.include?(file.path)
361
- next if file.processing || file.processed
362
-
363
- if includes && !includes.empty?
364
- should_include = find_in_patterns(includes, file)
365
- unless should_include
366
- add_to_ignore(file)
367
- next
368
- end
369
- end
370
-
371
- should_exclude = find_in_patterns(excludes, file)
372
- if should_exclude
373
- add_to_ignore(file)
374
- next
375
- end
376
-
377
- if @threaded
378
- active_processors.keep_if { |k, v| k.processing }
379
- if active_processors.length >= maximum_active_processors
380
- logger.debug { "Maximum number of active processors reached for watch folder. #{wf.name || wf.paths}" }
381
- break
382
- end
383
- t = Thread.new(file) do |file|
384
- wf = file.watch_folder
385
- begin
386
- process_file(file)
387
- rescue => e
388
- logger.error { "Exception '#{e.message}' in thread for `#{wf.name || wf.paths}` `#{file.path}`. " }
389
- raise e
390
- ensure
391
- file.processing = false rescue nil
392
- end
393
- end
394
- t.join
395
- active_processors[file] = t if file.processing
396
- else
397
- process_file(file)
398
- end
399
-
400
- end
401
- end
402
-
403
- # @param [Object] file
404
- # @return [Hash]
405
- def process_file(file)
406
- file.processing = true
407
- file_name = file.name || file.path
408
- logger.debug { "Processing File '#{file_name}'" }
409
-
410
- storage_id = watch_folder.definition['upload_to_storage_id']
411
-
412
- unless storage_id
413
- logger.warn { "Skipping processing of file because of missing storage ID." }
414
- return { success: false, message: 'Missing storage ID.' }
415
- end
416
-
417
- quarantine_directory_path = definition['quarantine_directory_path']
418
- completed_directory_path = definition['completed_directory_path']
419
- watch_folder_upload_args = definition['upload_args']
420
-
421
- # full_file_path = File.join(watch_folder.path, file.path)
422
- full_file_path = file.path
423
-
424
- upload_args = {
425
- file_path: full_file_path,
426
- storage_id: storage_id
427
- }
428
- upload_args.merge!(watch_folder_upload_args) if watch_folder_upload_args.is_a?(Hash)
429
-
430
- logger.debug { "Executing Upload. #{upload_args}" }
431
- _response = agent.upload(upload_args)
432
- _response = { success: _response } if _response == true || _response == false
433
-
434
- if _response[:success]
435
- if completed_directory_path
436
- if Dir.exist?(completed_directory_path)
437
- logger.debug { "Moving '#{full_file_path}' to completed directory path '#{completed_directory_path}'" }
438
- FileUtils.mv full_file_path, completed_directory_path
439
- else
440
- logger.warn { "Completed directory path not found: '#{completed_directory_path}'" }
441
- add_to_ignore(file)
442
- end
443
- else
444
- FileUtils.rm full_file_path
445
- end
446
- else
447
- if quarantine_directory_path && Dir.exist?(quarantine_directory_path)
448
- logger.warn { "Moving '#{full_file_path}' to quarantine directory path '#{quarantine_directory_path}'" }
449
- FileUtils.mv full_file_path, quarantine_directory_path
450
- else
451
- logger.warn { "Adding '#{full_file_path}' to the temporary ignore list." }
452
- add_to_ignore(file)
453
- end
454
- end
455
-
456
- file.processed = true
457
-
458
- _response
459
- rescue => e
460
- file.exception = e
461
- raise e
462
- ensure
463
- file.processing = false
464
- end
465
-
466
347
  # Converts hash keys to symbols
467
348
  #
468
349
  # @param [Hash] value hash
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cantemo-portal-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Whitson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-16 00:00:00.000000000 Z
11
+ date: 2019-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asperalm
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.3'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: listen
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.6.4
75
+ version: 1.6.5
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.6.4
82
+ version: 1.6.5
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -158,6 +158,7 @@ files:
158
158
  - lib/envoi/mam/agent/client/mediasilo.rb
159
159
  - lib/envoi/mam/agent/client/vidispine.rb
160
160
  - lib/envoi/mam/agent/config_service_client.rb
161
+ - lib/envoi/mam/agent/daemon/service_wrapper.rb
161
162
  - lib/envoi/mam/agent/generic.rb
162
163
  - lib/envoi/mam/agent/notifier.rb
163
164
  - lib/envoi/mam/agent/notifier/sns.rb