cantemo-portal-agent 1.2.9 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cb229847757ad05caf39b18d9bde4d612ca969d
4
- data.tar.gz: 94d3cda76321eea6cf31d3f603c9e8c3b84acb3e
3
+ metadata.gz: deef6be201da32030d9b495463c2c5b2a1a55086
4
+ data.tar.gz: 89ca91ba9fadf0f204cb9180ca28d3c3110766e7
5
5
  SHA512:
6
- metadata.gz: cfbad95315007919d44094139bd2469bfdaab96980ecbc729b74735aa3b15ce83d8175c8d92c77cc45076deff9ef794f1222833ea0716195854ba7832f4530a7
7
- data.tar.gz: 45e7685f7da882d16f378d5af4d3d67243423fbcd99488ad9398b905ca81802afc575af6db3de7003bd1a12f8c806780815a7a1651585460091a8ec1fae255d6
6
+ metadata.gz: 7f24e5db79bed7d457b59e0d845aff26e4f388e651ea5378a889ffcde36d3e5d1618a26ef570851501f391fead8ab3779017324ac4b2be668cdd07c7da53db14
7
+ data.tar.gz: 01d9ab468ba03278a8db51c057210cb8109ab96c37ff6ba719fb2bc581d08f0782695cb8e1d8f80dc99290e14e1547b1138313d236c4f3aa572872bb481a357e
@@ -46,8 +46,8 @@ op.on_tail('--help', 'Show this message.') { puts op; exit }
46
46
  op.load
47
47
  op.parse!
48
48
 
49
- command = (ARGV.first || 'run').downcase
50
- if command == 'help'
49
+ sub_command = (ARGV.first || 'run').downcase
50
+ if sub_command == 'help'
51
51
  puts op
52
52
  exit
53
53
  end
@@ -55,20 +55,14 @@ end
55
55
  config_file_path = args[:config_file_path]
56
56
  args[:config_file_path].map! { |v| File.expand_path(v) } if config_file_path.is_a?(Array)
57
57
 
58
- daemon_control_command_present = command && begin
59
- command = command.dup.downcase if command
60
- %w(start stop restart zap killall status).include?(command)
58
+ daemon_control_command_present = sub_command && begin
59
+ sub_command = sub_command.dup.downcase if sub_command
60
+ %w(start stop restart zap killall status).include?(sub_command)
61
61
  end
62
+ should_daemonize = (daemon_control_command_present && %w(start restart).include?(sub_command)) || args[:daemonize]
62
63
 
63
- if command == 'run'
64
- Envoi::Mam::Cantemo::Agent::WatchFolderManager.run(args)
65
- exit
66
- end
67
-
68
-
69
-
70
- if command
71
- case command
64
+ if sub_command
65
+ case sub_command
72
66
  when 'install'
73
67
  puts
74
68
  when 'uninstall'
@@ -78,15 +72,10 @@ if command
78
72
  end
79
73
  end
80
74
 
81
-
82
- should_daemonize = (daemon_control_command_present && %w(start restart).include?(command)) || args[:daemonize]
83
-
84
- # puts "#{__FILE__}:#{__LINE__ } #{args}"
85
- # next_command = ARGV.shift
86
- # puts "COMMAND: #{next_command}"
87
- #
88
- #
89
- #
75
+ if sub_command == 'run'
76
+ Envoi::Mam::Cantemo::Agent::WatchFolderManager.run(args)
77
+ exit
78
+ end
90
79
 
91
80
  module Application
92
81
 
@@ -148,9 +137,113 @@ module Application
148
137
 
149
138
  end
150
139
 
140
+ if !Application::OS.windows?
141
+ begin
142
+ Watcher.run_with_process_manager(args)
143
+ exit
144
+ rescue => e
145
+ abort("An error occurred. #{e.message}")
146
+ end
147
+ end
151
148
 
152
- begin
153
- Watcher.run_with_process_manager(args)
154
- rescue => e
155
- abort("An error occurred. #{e.message}")
149
+ # Options:
150
+ # install - Installs the service. The service name is "DemoSvc"
151
+ # and the display name is "Demo".
152
+ # start - Starts the service. Make sure you stop it at some point or
153
+ # you will eventually fill up your filesystem!.
154
+ # stop - Stops the service.
155
+ # pause - Pauses the service.
156
+ # resume - Resumes the service.
157
+ # uninstall - Uninstalls the service.
158
+ # delete - Same as uninstall.
159
+ require 'win32/service'
160
+ require 'rbconfig'
161
+ include Win32
162
+ include RbConfig
163
+
164
+ # Make sure you're using the version you think you're using.
165
+ puts 'VERSION: ' + Service::VERSION
166
+
167
+ SERVICE_NAME = 'cantemo_portal_watch_folder_agent'
168
+ SERVICE_DISPLAYNAME = 'Cantemo Portal Watch Folder Agent'
169
+ EXECUTABLE_NAME = __FILE__
170
+
171
+
172
+ # You must provide at least one argument.
173
+ raise ArgumentError, 'No argument provided' unless sub_command
174
+
175
+ case sub_command
176
+ when 'install'
177
+ # Quote the full path to deal with possible spaces in the path name.
178
+ ruby = File.join(CONFIG['bindir'], CONFIG['ruby_install_name']).tr('/', '\\')
179
+ path = %Q(#{File.dirname(File.expand_path($0)).tr('/', '\\')}\\#{EXECUTABLE_NAME})
180
+ cmd = %Q("#{ruby}" "#{path}" run --config-file-path "#{config_file_path}")
181
+
182
+ Service.new(
183
+ :service_name => SERVICE_NAME,
184
+ :display_name => SERVICE_DISPLAYNAME,
185
+ :description => 'Watch Folder Agent for Cantemo Portal',
186
+ :binary_path_name => cmd
187
+ )
188
+ puts 'Service ' + SERVICE_NAME + ' installed'
189
+ when 'start'
190
+ if Service.status(SERVICE_NAME).current_state != 'running'
191
+ Service.start(SERVICE_NAME, nil)
192
+ while Service.status(SERVICE_NAME).current_state != 'running'
193
+ puts 'One moment...' + Service.status(SERVICE_NAME).current_state
194
+ sleep 1
195
+ end
196
+ puts 'Service ' + SERVICE_NAME + ' started'
197
+ else
198
+ puts 'Already running'
199
+ end
200
+ when 'stop'
201
+ if Service.status(SERVICE_NAME).current_state != 'stopped'
202
+ Service.stop(SERVICE_NAME)
203
+ while Service.status(SERVICE_NAME).current_state != 'stopped'
204
+ puts 'One moment...' + Service.status(SERVICE_NAME).current_state
205
+ sleep 1
206
+ end
207
+ puts 'Service ' + SERVICE_NAME + ' stopped'
208
+ else
209
+ puts 'Already stopped'
210
+ end
211
+ when 'uninstall', 'delete'
212
+ if Service.status(SERVICE_NAME).current_state != 'stopped'
213
+ Service.stop(SERVICE_NAME)
214
+ end
215
+ while Service.status(SERVICE_NAME).current_state != 'stopped'
216
+ puts 'One moment...' + Service.status(SERVICE_NAME).current_state
217
+ sleep 1
218
+ end
219
+ Service.delete(SERVICE_NAME)
220
+ puts 'Service ' + SERVICE_NAME + ' deleted'
221
+ when 'pause'
222
+ if Service.status(SERVICE_NAME).current_state != 'paused'
223
+ Service.pause(SERVICE_NAME)
224
+ while Service.status(SERVICE_NAME).current_state != 'paused'
225
+ puts 'One moment...' + Service.status(SERVICE_NAME).current_state
226
+ sleep 1
227
+ end
228
+ puts 'Service ' + SERVICE_NAME + ' paused'
229
+ else
230
+ puts 'Already paused'
231
+ end
232
+ when 'resume'
233
+ if Service.status(SERVICE_NAME).current_state != 'running'
234
+ Service.resume(SERVICE_NAME)
235
+ while Service.status(SERVICE_NAME).current_state != 'running'
236
+ puts 'One moment...' + Service.status(SERVICE_NAME).current_state
237
+ sleep 1
238
+ end
239
+ puts 'Service ' + SERVICE_NAME + ' resumed'
240
+ else
241
+ puts 'Already running'
242
+ end
243
+ when 'status'
244
+ puts Service.status(SERVICE_NAME)
245
+ else
246
+ raise ArgumentError, 'unknown option: ' + sub_command
156
247
  end
248
+
249
+
@@ -1,7 +1,7 @@
1
1
  module Cantemo
2
2
  module Portal
3
3
  class Agent
4
- VERSION = '1.2.9'.freeze
4
+ VERSION = '1.3.0'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cantemo-portal-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Whitson