cantemo-portal-agent 1.2.3 → 1.2.4

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: 4ee35911bd6bae5512fa8dbd656bcf191fe548f9
4
- data.tar.gz: dcf5c261b9b184b9734c3b0cc9d4e9c996464e98
3
+ metadata.gz: de359aa5f03562ec1007a7bdb3a9dc0af6362216
4
+ data.tar.gz: 1fb3d59042129c18561dd1504a9ace1a5508a385
5
5
  SHA512:
6
- metadata.gz: 0fcf6fe6526c7db201d74242d7d13d897944ab2ff0b0d09bb2adec07e98c3053dabd1abd083b5b4c0f5afc50153ed3dfcdbbf7a2c6c1517d6b43e5c16d293f03
7
- data.tar.gz: 28e97981b20cc01ff0c379483d5d52717f9ef07ed7e013c62bcc32cd5b133f592b19b1bd3b5afbc5a8e84e0f460f4557547d2411fe7206f4cd1d725a66567c89
6
+ metadata.gz: 4a75c0ac6f20dedffbfb5cd7575828ea43ea29c75b1c4fea6f56c029ac4ef89dcd7d740d2b048bb04f3c455ef3420f4b7c16264ac799d7f0d4b6334dda0f87b2
7
+ data.tar.gz: b793017b7a68087dd13d1a278c9f37ca2cbf77bbf4a29455b9dd7f70f97ac137e4c3304698027c8cb37bb988855ff560f46da54782be700ede429b4750ee10a3
@@ -9,7 +9,6 @@ require 'pp'
9
9
 
10
10
  require 'envoi/mam/agent/cli'
11
11
  require 'envoi/mam/cantemo/agent'
12
- # require 'envoi/aspera/watch_service/watch_folder'
13
12
  require 'envoi/mam/cantemo/agent/watch_folder_manager'
14
13
 
15
14
  Envoi::Mam::Agent::CLI::CONFIG_FILE_PATHS.clear
@@ -20,10 +19,6 @@ Envoi::Mam::Agent::CLI::CONFIG_FILE_PATHS.concat [
20
19
  '~/.cantemo-portal-agent-config.json',
21
20
  ]
22
21
  default_config_file_paths = Envoi::Mam::Agent::CLI::CONFIG_FILE_PATHS
23
-
24
- # aspera_ascp_paths = Envoi::Mam::Agent::TransferClient::Aspera::ASCP_PATHS
25
- # default_aspera_ascp_path = aspera_ascp_paths.find { |v| File.exist? v } || aspera_ascp_paths.first
26
-
27
22
  current_command = ARGV.shift
28
23
  ARGV << 'run' if ARGV.empty?
29
24
  # ARGV << '--help' if ARGV.empty?
@@ -68,13 +63,17 @@ if command
68
63
  end
69
64
 
70
65
 
71
- daemonize = (daemon_control_command_present && %w(start restart).include?(command)) || args[:daemonize]
66
+ should_daemonize = (daemon_control_command_present && %w(start restart).include?(command)) || args[:daemonize]
72
67
 
73
68
  # puts "#{__FILE__}:#{__LINE__ } #{args}"
74
69
  # next_command = ARGV.shift
75
70
  # puts "COMMAND: #{next_command}"
71
+ #
72
+ #
73
+
74
+
76
75
 
77
76
  class Watcher < Envoi::Mam::Cantemo::Agent::WatchFolderManager; end
78
77
  # daemonize ? Watcher.run_as_daemon(args, { force: true }) : Watcher.run(args)
79
78
  # daemon_control_command_present ? Watcher.run_as_daemon(args) : Watcher.run(args)
80
- Watcher.run_as_daemon(args)
79
+ Watcher.run_with_process_manager(args)
@@ -1,7 +1,7 @@
1
1
  module Cantemo
2
2
  module Portal
3
3
  class Agent
4
- VERSION = '1.2.3'.freeze
4
+ VERSION = '1.2.4'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,13 @@
1
+ require 'envoi/mam/agent/cli'
2
+ require 'envoi/mam/cantemo/agent'
3
+ # require 'envoi/aspera/watch_service/watch_folder'
4
+ require 'envoi/mam/cantemo/agent/watch_folder_manager'
5
+
6
+ Envoi::Mam::Agent::CLI::CONFIG_FILE_PATHS.clear
7
+ Envoi::Mam::Agent::CLI::CONFIG_FILE_PATHS.concat [
8
+ './cantemo-portal-agent-config.json',
9
+ '~/cantemo-portal-agent-config.json',
10
+ './.cantemo-portal-agent-config.json',
11
+ '~/.cantemo-portal-agent-config.json',
12
+ ]
13
+ default_config_file_paths = Envoi::Mam::Agent::CLI::CONFIG_FILE_PATHS
@@ -5,6 +5,24 @@ require 'envoi/watch_folder_utility/watch_folder/handler/listen'
5
5
 
6
6
  module Envoi::Mam::Cantemo
7
7
 
8
+ module OS
9
+ def OS.windows?
10
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
11
+ end
12
+
13
+ def OS.mac?
14
+ (/darwin/ =~ RUBY_PLATFORM) != nil
15
+ end
16
+
17
+ def OS.unix?
18
+ !OS.windows?
19
+ end
20
+
21
+ def OS.linux?
22
+ OS.unix? and not OS.mac?
23
+ end
24
+ end
25
+
8
26
  class Agent
9
27
 
10
28
  class WatchFolderManager
@@ -93,6 +111,9 @@ module Envoi::Mam::Cantemo
93
111
 
94
112
  # Iterates through watch_folder_defs and populates @watch_folders with watch folders initialized from the watch
95
113
  # folder definitions
114
+ #
115
+ # Supports both array and hash formats, the hash format will use the key as the mame if the definition doesn't
116
+ # already have a name set
96
117
  def process_watch_folder_defs
97
118
  logger.debug { 'Processing watch folder definitions.' }
98
119
  if watch_folder_defs.is_a?(Array)
@@ -201,8 +222,7 @@ module Envoi::Mam::Cantemo
201
222
 
202
223
  stable_files.each do |file|
203
224
  next if file.respond_to?(:ignore?) ? file.ignore? : ignored_file_paths.include?(file.path)
204
- next if file.processing
205
- next if file.processed
225
+ next if file.processing || file.processed
206
226
 
207
227
  if includes && !includes.empty?
208
228
  should_include = find_in_patterns(includes, file)
@@ -355,18 +375,25 @@ module Envoi::Mam::Cantemo
355
375
 
356
376
  end
357
377
 
358
- def self.run_as_daemon(args, options = {})
378
+ def self.run_with_process_manager(args, options = {})
359
379
  # ARGV.unshift 'run' unless %w(start stop restart run zap killall status).include? ARGV.first
360
- require 'daemons'
361
- proc = Proc.new { self.run(args) }
362
- app_name = 'cantemo-portal-watch-folders'
380
+ if OS.windows?
381
+ self.run(args)
382
+ else
383
+ require 'daemons'
384
+ proc = Proc.new { self.run(args) }
385
+ app_name = 'cantemo-portal-watch-folders'
363
386
 
364
- # options[:app_name] = app_name
365
- # daemons_run_proc_with_cleanup(options, &proc)
387
+ # options[:app_name] = app_name
388
+ # daemons_run_proc_with_cleanup(options, &proc)
366
389
 
367
- # options[:force] = true
368
- Daemons.run_proc(app_name, options, &proc)
390
+ # options[:force] = true
391
+ Daemons.run_proc(app_name, options, &proc)
392
+ end
393
+ end
369
394
 
395
+ def self.run_in_foreground(args, options = { })
396
+ self.run(args)
370
397
  end
371
398
 
372
399
  end
@@ -20,7 +20,6 @@ module Envoi
20
20
  :min_stable_time,
21
21
  :poll_interval
22
22
 
23
-
24
23
  def initialize(args = { })
25
24
  initialize_logger(args)
26
25
  @definition = args[:definition].dup
@@ -42,6 +41,8 @@ module Envoi
42
41
  @default_agent = args[:default_agent]
43
42
  @default_agent_class = args[:default_agent_class] || @default_agent.class
44
43
 
44
+ @last_poll_time = nil
45
+
45
46
  process_agent_defs
46
47
  logger.debug { "Watch Folder Initialized. #{Object.__id__}" }
47
48
  end
@@ -274,10 +275,8 @@ module Envoi
274
275
  agents = agents.map { |k,v| v['name'] ||= k; v }
275
276
  end
276
277
  if agent
277
- if agent.is_a?(Hash)
278
- if agent.keys.length == 1
279
- agent = agent.map { |k,v| v['name'] ||= k; v }
280
- end
278
+ if agent.is_a?(Hash) && agent.keys.length == 1
279
+ agent = agent.map { |k,v| v['name'] ||= k; v }
281
280
  end
282
281
  agents.concat [*agent]
283
282
  watch_folder_def.delete('agent')
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.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Whitson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-20 00:00:00.000000000 Z
11
+ date: 2019-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asperalm
@@ -168,6 +168,7 @@ files:
168
168
  - lib/envoi/mam/agent/version.rb
169
169
  - lib/envoi/mam/agent/watch_folder_utility/foreman.rb
170
170
  - lib/envoi/mam/cantemo/agent.rb
171
+ - lib/envoi/mam/cantemo/agent/cli.rb
171
172
  - lib/envoi/mam/cantemo/agent/watch_folder_handler-working.rb
172
173
  - lib/envoi/mam/cantemo/agent/watch_folder_handler_aspera.rb
173
174
  - lib/envoi/mam/cantemo/agent/watch_folder_manager.rb