procon_bypass_man 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -3
- data/Gemfile.lock +1 -1
- data/Steepfile +0 -1
- data/bin/generate_output_report +18 -0
- data/lib/procon_bypass_man/background/jobs/post_completed_remote_action_job.rb +20 -0
- data/lib/procon_bypass_man/background/jobs/report_info_log_job.rb +11 -0
- data/lib/procon_bypass_man/background.rb +1 -0
- data/lib/procon_bypass_man/bypass/procon_to_switch.rb +3 -0
- data/lib/procon_bypass_man/commands/send_info_log_command.rb +11 -0
- data/lib/procon_bypass_man/commands.rb +1 -0
- data/lib/procon_bypass_man/configuration.rb +1 -1
- data/lib/procon_bypass_man/procon.rb +22 -11
- data/lib/procon_bypass_man/procon_display/status.rb +1 -0
- data/lib/procon_bypass_man/procon_display.rb +0 -1
- data/lib/procon_bypass_man/{remote_macro → remote_action}/queue_over_process.rb +2 -2
- data/lib/procon_bypass_man/{remote_macro/remote_macro_object.rb → remote_action/remote_action_object.rb} +1 -1
- data/lib/procon_bypass_man/{remote_macro/remote_macro_receiver.rb → remote_action/remote_action_receiver.rb} +8 -7
- data/lib/procon_bypass_man/remote_action/remote_action_sender.rb +9 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb +55 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/change_pbm_version_action.rb +31 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/commands/run_remote_pbm_job_dispatch_command.rb +29 -0
- data/lib/procon_bypass_man/{remote_pbm_action/commands/update_remote_pbm_action_status_command.rb → remote_action/remote_pbm_job/commands/update_remote_pbm_job_status_command.rb} +2 -2
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/reboot_os_action.rb +24 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/report_procon_status.rb +25 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb +42 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/stop_pbm_action.rb +23 -0
- data/lib/procon_bypass_man/{remote_pbm_action/value_objects/remote_pbm_action_object.rb → remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb} +2 -2
- data/lib/procon_bypass_man/remote_action/remote_pbm_job.rb +45 -0
- data/lib/procon_bypass_man/remote_action/task.rb +14 -0
- data/lib/procon_bypass_man/{remote_macro → remote_action}/task_queue.rb +1 -1
- data/lib/procon_bypass_man/remote_action.rb +19 -0
- data/lib/procon_bypass_man/support/callbacks.rb +1 -0
- data/lib/procon_bypass_man/support/{update_remote_pbm_action_status_http_client.rb → update_remote_pbm_job_status_http_client.rb} +1 -1
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/client.rb +42 -26
- data/lib/procon_bypass_man.rb +5 -7
- data/project_template/app.rb +1 -1
- data/project_template/app.rb.erb +1 -1
- data/sig/main.rbs +0 -6
- metadata +24 -20
- data/lib/procon_bypass_man/procon_display/bypass_hook.rb +0 -12
- data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +0 -8
- data/lib/procon_bypass_man/remote_macro/task.rb +0 -2
- data/lib/procon_bypass_man/remote_macro.rb +0 -16
- data/lib/procon_bypass_man/remote_pbm_action/base_action.rb +0 -53
- data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +0 -29
- data/lib/procon_bypass_man/remote_pbm_action/commands/run_remote_pbm_action_dispatch_command.rb +0 -21
- data/lib/procon_bypass_man/remote_pbm_action/reboot_os_action.rb +0 -22
- data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +0 -41
- data/lib/procon_bypass_man/remote_pbm_action/stop_pbm_action.rb +0 -21
- data/lib/procon_bypass_man/remote_pbm_action.rb +0 -36
@@ -59,59 +59,75 @@ module ProconBypassMan
|
|
59
59
|
|
60
60
|
# @param [Hash] data
|
61
61
|
def self.dispatch(data: , client: )
|
62
|
-
|
63
|
-
case pbm_job_hash['action']
|
62
|
+
case data.dig("message")['action']
|
64
63
|
when "ping"
|
65
64
|
client.perform('pong', { device_id: ProconBypassMan.device_id, message: 'hello from pbm' })
|
66
|
-
when ProconBypassMan::
|
67
|
-
|
68
|
-
when *ProconBypassMan::
|
69
|
-
|
65
|
+
when ProconBypassMan::RemoteAction::ACTION_MACRO
|
66
|
+
run_remote_macro(data: data)
|
67
|
+
when *ProconBypassMan::RemoteAction::RemotePbmJob::ACTIONS_IN_MASTER_PROCESS
|
68
|
+
run_remote_pbm_job(data: data, process_to_execute: :master)
|
69
|
+
when *ProconBypassMan::RemoteAction::RemotePbmJob::ACTIONS_IN_BYPASS_PROCESS
|
70
|
+
run_remote_pbm_job(data: data, process_to_execute: :bypass)
|
70
71
|
else
|
71
|
-
ProconBypassMan.
|
72
|
+
ProconBypassMan::SendErrorCommand.execute(error: 'unknown remote pbm action')
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
# @raise [ProconBypassMan::
|
76
|
+
# @raise [ProconBypassMan::RemotePbmJobObject::ValidationError]
|
76
77
|
# @param [Hash] data
|
78
|
+
# @param [Symbol] process_to_execute どのプロセスで実行するか
|
77
79
|
# @return [Void]
|
78
|
-
def self.
|
80
|
+
def self.run_remote_pbm_job(data: , process_to_execute: )
|
79
81
|
pbm_job_hash = data.dig("message")
|
80
82
|
begin
|
81
|
-
pbm_job_object = ProconBypassMan::
|
83
|
+
pbm_job_object = ProconBypassMan::RemotePbmJobObject.new(action: pbm_job_hash["action"],
|
82
84
|
status: pbm_job_hash["status"],
|
83
85
|
uuid: pbm_job_hash["uuid"],
|
84
86
|
created_at: pbm_job_hash["created_at"],
|
85
87
|
job_args: pbm_job_hash["args"])
|
86
88
|
pbm_job_object.validate!
|
87
|
-
rescue ProconBypassMan::
|
89
|
+
rescue ProconBypassMan::RemotePbmJobObject::ValidationError => e
|
88
90
|
ProconBypassMan::SendErrorCommand.execute(error: e)
|
89
91
|
return
|
90
92
|
end
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
case process_to_execute
|
95
|
+
when :master
|
96
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::RunRemotePbmJobDispatchCommand.execute(
|
97
|
+
action: pbm_job_object.action,
|
98
|
+
uuid: pbm_job_object.uuid,
|
99
|
+
job_args: pbm_job_object.job_args
|
100
|
+
)
|
101
|
+
when :bypass
|
102
|
+
ProconBypassMan::RemoteAction::QueueOverProcess.push(
|
103
|
+
ProconBypassMan::RemoteAction::Task.new(pbm_job_object.action,
|
104
|
+
pbm_job_object.uuid,
|
105
|
+
pbm_job_object.job_args,
|
106
|
+
ProconBypassMan::RemoteAction::Task::TYPE_ACTION)
|
107
|
+
)
|
108
|
+
else
|
109
|
+
ProconBypassMan::SendErrorCommand.execute(error: 'unknown process to execute')
|
110
|
+
end
|
97
111
|
end
|
98
112
|
|
99
|
-
def self.
|
113
|
+
def self.run_remote_macro(data: )
|
100
114
|
pbm_job_hash = data.dig("message")
|
101
115
|
begin
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
rescue ProconBypassMan::
|
116
|
+
remote_action_object = ProconBypassMan::RemoteAction::RemoteActionObject.new(name: pbm_job_hash["name"],
|
117
|
+
uuid: pbm_job_hash["uuid"],
|
118
|
+
steps: pbm_job_hash["steps"])
|
119
|
+
remote_action_object.validate!
|
120
|
+
rescue ProconBypassMan::RemoteAction::RemoteActionObject::ValidationError => e
|
107
121
|
ProconBypassMan::SendErrorCommand.execute(error: e)
|
108
122
|
return
|
109
123
|
end
|
110
124
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
125
|
+
# TODO: インラインしたい
|
126
|
+
ProconBypassMan::RemoteActionSender.execute(
|
127
|
+
name: remote_action_object.name,
|
128
|
+
uuid: remote_action_object.uuid,
|
129
|
+
steps: remote_action_object.steps,
|
130
|
+
type: ProconBypassMan::RemoteAction::Task::TYPE_MACRO,
|
115
131
|
)
|
116
132
|
end
|
117
133
|
end
|
data/lib/procon_bypass_man.rb
CHANGED
@@ -31,7 +31,7 @@ require_relative "procon_bypass_man/support/on_memory_cache"
|
|
31
31
|
require_relative "procon_bypass_man/support/http_client"
|
32
32
|
require_relative "procon_bypass_man/support/report_http_client"
|
33
33
|
require_relative "procon_bypass_man/support/remote_macro_http_client"
|
34
|
-
require_relative "procon_bypass_man/support/
|
34
|
+
require_relative "procon_bypass_man/support/update_remote_pbm_job_status_http_client"
|
35
35
|
require_relative "procon_bypass_man/support/send_device_stats_http_client"
|
36
36
|
require_relative "procon_bypass_man/support/procon_performance_http_client"
|
37
37
|
require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
|
@@ -55,7 +55,6 @@ require_relative "procon_bypass_man/device_model"
|
|
55
55
|
require_relative "procon_bypass_man/procon/button"
|
56
56
|
require_relative "procon_bypass_man/procon/analog_stick_cap"
|
57
57
|
require_relative "procon_bypass_man/procon/analog_stick_manipulator"
|
58
|
-
require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
|
59
58
|
require_relative "procon_bypass_man/scheduler"
|
60
59
|
require_relative "procon_bypass_man/plugins"
|
61
60
|
require_relative "procon_bypass_man/worker"
|
@@ -63,8 +62,7 @@ require_relative "procon_bypass_man/websocket/client"
|
|
63
62
|
require_relative "procon_bypass_man/websocket/watchdog"
|
64
63
|
require_relative "procon_bypass_man/websocket/forever"
|
65
64
|
|
66
|
-
require_relative "procon_bypass_man/
|
67
|
-
require_relative "procon_bypass_man/remote_macro"
|
65
|
+
require_relative "procon_bypass_man/remote_action"
|
68
66
|
|
69
67
|
STDOUT.sync = true
|
70
68
|
Thread.abort_on_exception = true
|
@@ -161,7 +159,7 @@ module ProconBypassMan
|
|
161
159
|
ProconBypassMan::Background::JobQueue.start!
|
162
160
|
ProconBypassMan::Websocket::Client.start!
|
163
161
|
# TODO ProconBypassMan::DrbObjects.start_all! みたいな感じで書きたい
|
164
|
-
ProconBypassMan::
|
162
|
+
ProconBypassMan::RemoteAction::QueueOverProcess.start!
|
165
163
|
ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.start!
|
166
164
|
ProconBypassMan::Scheduler.start!
|
167
165
|
|
@@ -193,7 +191,7 @@ module ProconBypassMan
|
|
193
191
|
BlueGreenProcess.configure do |config|
|
194
192
|
config.after_fork = -> {
|
195
193
|
DRb.start_service if defined?(DRb)
|
196
|
-
ProconBypassMan::
|
194
|
+
ProconBypassMan::RemoteActionReceiver.start!
|
197
195
|
BlueGreenProcess.config.logger = ProconBypassMan.logger
|
198
196
|
}
|
199
197
|
config.shared_variables = [:buttons, :current_layer_key, :recent_left_stick_hypotenuses]
|
@@ -204,7 +202,7 @@ module ProconBypassMan
|
|
204
202
|
def self.terminate_pbm
|
205
203
|
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
206
204
|
FileUtils.rm_rf(ProconBypassMan.digest_path)
|
207
|
-
ProconBypassMan::
|
205
|
+
ProconBypassMan::RemoteAction::QueueOverProcess.shutdown
|
208
206
|
ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.shutdown
|
209
207
|
self.worker&.shutdown
|
210
208
|
end
|
data/project_template/app.rb
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
gemfile do
|
13
13
|
source 'https://rubygems.org'
|
14
14
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
15
|
-
gem 'procon_bypass_man', '0.3.
|
15
|
+
gem 'procon_bypass_man', '0.3.6'
|
16
16
|
end
|
17
17
|
rescue Bundler::Source::Git::GitCommandError => e
|
18
18
|
retry_count_on_git_command_error = retry_count_on_git_command_error + 1
|
data/project_template/app.rb.erb
CHANGED
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
gemfile do
|
13
13
|
source 'https://rubygems.org'
|
14
14
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
15
|
-
gem 'procon_bypass_man', '0.3.
|
15
|
+
gem 'procon_bypass_man', '0.3.6'
|
16
16
|
end
|
17
17
|
rescue Bundler::Source::Git::GitCommandError => e
|
18
18
|
retry_count_on_git_command_error = retry_count_on_git_command_error + 1
|
data/sig/main.rbs
CHANGED
@@ -613,12 +613,6 @@ module ProconBypassMan
|
|
613
613
|
end
|
614
614
|
end
|
615
615
|
|
616
|
-
module ProconBypassMan
|
617
|
-
class UpdateRemotePbmActionStatusHttpClient
|
618
|
-
def post: (to_status: ::Symbol) -> untyped
|
619
|
-
end
|
620
|
-
end
|
621
|
-
|
622
616
|
module ProconBypassMan
|
623
617
|
class CompressArray
|
624
618
|
@array: [String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procon_bypass_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pbmenv
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- bin/console
|
94
94
|
- bin/dev_api_server.rb
|
95
95
|
- bin/generate_default_app
|
96
|
+
- bin/generate_output_report
|
96
97
|
- bin/setup
|
97
98
|
- docs/getting_started.md
|
98
99
|
- docs/how_to_connect_procon.md
|
@@ -119,12 +120,14 @@ files:
|
|
119
120
|
- lib/procon_bypass_man/background/jobs/base_job.rb
|
120
121
|
- lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
|
121
122
|
- lib/procon_bypass_man/background/jobs/concerns/job_performable.rb
|
123
|
+
- lib/procon_bypass_man/background/jobs/post_completed_remote_action_job.rb
|
122
124
|
- lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb
|
123
125
|
- lib/procon_bypass_man/background/jobs/report_boot_job.rb
|
124
126
|
- lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
|
125
127
|
- lib/procon_bypass_man/background/jobs/report_error_job.rb
|
126
128
|
- lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb
|
127
129
|
- lib/procon_bypass_man/background/jobs/report_event_base_job.rb
|
130
|
+
- lib/procon_bypass_man/background/jobs/report_info_log_job.rb
|
128
131
|
- lib/procon_bypass_man/background/jobs/report_load_config_job.rb
|
129
132
|
- lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb
|
130
133
|
- lib/procon_bypass_man/background/jobs/report_reload_config_job.rb
|
@@ -154,6 +157,7 @@ files:
|
|
154
157
|
- lib/procon_bypass_man/commands/print_boot_message_command.rb
|
155
158
|
- lib/procon_bypass_man/commands/print_message_command.rb
|
156
159
|
- lib/procon_bypass_man/commands/send_error_command.rb
|
160
|
+
- lib/procon_bypass_man/commands/send_info_log_command.rb
|
157
161
|
- lib/procon_bypass_man/commands/send_reload_config_event_command.rb
|
158
162
|
- lib/procon_bypass_man/commands/send_warning_command.rb
|
159
163
|
- lib/procon_bypass_man/commands/write_device_id_command.rb
|
@@ -232,28 +236,28 @@ files:
|
|
232
236
|
- lib/procon_bypass_man/procon/value_objects/procon_reader.rb
|
233
237
|
- lib/procon_bypass_man/procon/value_objects/rumble_binary.rb
|
234
238
|
- lib/procon_bypass_man/procon_display.rb
|
235
|
-
- lib/procon_bypass_man/procon_display/bypass_hook.rb
|
236
239
|
- lib/procon_bypass_man/procon_display/http_request.rb
|
237
240
|
- lib/procon_bypass_man/procon_display/http_response.rb
|
238
241
|
- lib/procon_bypass_man/procon_display/server.rb
|
239
242
|
- lib/procon_bypass_man/procon_display/server_app.rb
|
240
243
|
- lib/procon_bypass_man/procon_display/status.rb
|
241
|
-
- lib/procon_bypass_man/
|
242
|
-
- lib/procon_bypass_man/
|
243
|
-
- lib/procon_bypass_man/
|
244
|
-
- lib/procon_bypass_man/
|
245
|
-
- lib/procon_bypass_man/
|
246
|
-
- lib/procon_bypass_man/
|
247
|
-
- lib/procon_bypass_man/
|
248
|
-
- lib/procon_bypass_man/
|
249
|
-
- lib/procon_bypass_man/
|
250
|
-
- lib/procon_bypass_man/
|
251
|
-
- lib/procon_bypass_man/
|
252
|
-
- lib/procon_bypass_man/
|
253
|
-
- lib/procon_bypass_man/
|
254
|
-
- lib/procon_bypass_man/
|
255
|
-
- lib/procon_bypass_man/
|
256
|
-
- lib/procon_bypass_man/
|
244
|
+
- lib/procon_bypass_man/remote_action.rb
|
245
|
+
- lib/procon_bypass_man/remote_action/queue_over_process.rb
|
246
|
+
- lib/procon_bypass_man/remote_action/remote_action_object.rb
|
247
|
+
- lib/procon_bypass_man/remote_action/remote_action_receiver.rb
|
248
|
+
- lib/procon_bypass_man/remote_action/remote_action_sender.rb
|
249
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job.rb
|
250
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
|
251
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/change_pbm_version_action.rb
|
252
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/commands/run_remote_pbm_job_dispatch_command.rb
|
253
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/commands/update_remote_pbm_job_status_command.rb
|
254
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/reboot_os_action.rb
|
255
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/report_procon_status.rb
|
256
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
|
257
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/stop_pbm_action.rb
|
258
|
+
- lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
|
259
|
+
- lib/procon_bypass_man/remote_action/task.rb
|
260
|
+
- lib/procon_bypass_man/remote_action/task_queue.rb
|
257
261
|
- lib/procon_bypass_man/runner.rb
|
258
262
|
- lib/procon_bypass_man/scheduler.rb
|
259
263
|
- lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb
|
@@ -274,7 +278,7 @@ files:
|
|
274
278
|
- lib/procon_bypass_man/support/retryable.rb
|
275
279
|
- lib/procon_bypass_man/support/safe_timeout.rb
|
276
280
|
- lib/procon_bypass_man/support/send_device_stats_http_client.rb
|
277
|
-
- lib/procon_bypass_man/support/
|
281
|
+
- lib/procon_bypass_man/support/update_remote_pbm_job_status_http_client.rb
|
278
282
|
- lib/procon_bypass_man/support/uptime.rb
|
279
283
|
- lib/procon_bypass_man/support/usb_device_controller.rb
|
280
284
|
- lib/procon_bypass_man/support/yaml_loader.rb
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module ProconBypassMan::ProconDisplay::BypassHook
|
2
|
-
include ProconBypassMan::Callbacks
|
3
|
-
|
4
|
-
define_callbacks :run
|
5
|
-
|
6
|
-
set_callback :run, :after, :write_procon_display_status
|
7
|
-
|
8
|
-
def write_procon_display_status
|
9
|
-
return unless bypass_value.binary
|
10
|
-
ProconBypassMan::ProconDisplay::Status.instance.current = bypass_value.binary.to_procon_reader.to_hash.dup
|
11
|
-
end
|
12
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
class ProconBypassMan::RemoteMacroSender
|
2
|
-
def self.execute(name: , uuid: , steps: )
|
3
|
-
ProconBypassMan.logger.info "[remote macro][sender] name: #{name}, uuid: #{uuid}, steps: #{steps}"
|
4
|
-
ProconBypassMan::RemoteMacro::QueueOverProcess.push(
|
5
|
-
ProconBypassMan::RemoteMacro::Task.new(name, uuid, steps)
|
6
|
-
)
|
7
|
-
end
|
8
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ProconBypassMan
|
4
|
-
module RemoteMacro
|
5
|
-
require "procon_bypass_man/remote_macro/remote_macro_object"
|
6
|
-
require "procon_bypass_man/remote_macro/remote_macro_receiver"
|
7
|
-
require "procon_bypass_man/remote_macro/remote_macro_sender"
|
8
|
-
require "procon_bypass_man/remote_macro/queue_over_process"
|
9
|
-
require "procon_bypass_man/remote_macro/task"
|
10
|
-
require "procon_bypass_man/remote_macro/task_queue"
|
11
|
-
|
12
|
-
ACTION_KEY = "remote_macro"
|
13
|
-
|
14
|
-
TaskQueueInProcess = ProconBypassMan::RemoteMacro::TaskQueue.new
|
15
|
-
end
|
16
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module RemotePbmAction
|
3
|
-
class ActionUnexpectedError < StandardError; end
|
4
|
-
class NeedPbmVersionError < ActionUnexpectedError; end
|
5
|
-
|
6
|
-
class BaseAction
|
7
|
-
attr_accessor :pbm_job_uuid
|
8
|
-
|
9
|
-
# @param [String] pbm_job_uuid
|
10
|
-
def initialize(pbm_job_uuid: )
|
11
|
-
self.pbm_job_uuid = pbm_job_uuid
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [void]
|
15
|
-
def action_content(_args)
|
16
|
-
raise NotImplementedError, nil
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param [Hash] args
|
20
|
-
# @return [void]
|
21
|
-
def run!(job_args: )
|
22
|
-
before_action_callback
|
23
|
-
action_content(args: job_args)
|
24
|
-
after_action_callback
|
25
|
-
rescue => e
|
26
|
-
be_failed
|
27
|
-
ProconBypassMan::SendErrorCommand.execute(error: e)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
# @return [void]
|
33
|
-
def before_action_callback; end
|
34
|
-
# @return [void]
|
35
|
-
def after_action_callback; end
|
36
|
-
|
37
|
-
# @return [void]
|
38
|
-
def be_failed
|
39
|
-
ProconBypassMan::UpdateRemotePbmActionStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :failed)
|
40
|
-
end
|
41
|
-
|
42
|
-
# @return [void]
|
43
|
-
def be_in_progress
|
44
|
-
ProconBypassMan::UpdateRemotePbmActionStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :in_progress)
|
45
|
-
end
|
46
|
-
|
47
|
-
# @return [void]
|
48
|
-
def be_processed
|
49
|
-
ProconBypassMan::UpdateRemotePbmActionStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :processed)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module RemotePbmAction
|
3
|
-
class ChangePbmVersionAction < BaseAction
|
4
|
-
|
5
|
-
def action_content(args: )
|
6
|
-
require "pbmenv"
|
7
|
-
ProconBypassMan.logger.info "execute ChangePbmVersionAction!"
|
8
|
-
pbm_version = args["pbm_version"] or raise(ProconBypassMan::RemotePbmAction::NeedPbmVersionError, "pbm_versionが必要です, #{args.inspect}")
|
9
|
-
Pbmenv.uninstall(pbm_version) # 途中でシャットダウンしてしまった、とか状態が途中の状態かもしれないので一旦消す
|
10
|
-
Pbmenv.install(pbm_version, enable_pbm_cloud: true)
|
11
|
-
Pbmenv.use(pbm_version)
|
12
|
-
Pbmenv.clean(10)
|
13
|
-
ProconBypassMan.logger.info "#{pbm_version}へアップグレードしました"
|
14
|
-
ProconBypassMan::ReportCompletedUpgradePbmJob.perform
|
15
|
-
`reboot` # symlinkの参照先が変わるのでrebootする必要がある
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def before_action_callback
|
21
|
-
be_processed
|
22
|
-
end
|
23
|
-
|
24
|
-
def after_action_callback
|
25
|
-
# no-op
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/procon_bypass_man/remote_pbm_action/commands/run_remote_pbm_action_dispatch_command.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class ProconBypassMan::RunRemotePbmActionDispatchCommand
|
2
|
-
# @param [String] action
|
3
|
-
# @param [String] uuid
|
4
|
-
# @return [void]
|
5
|
-
def self.execute(action: , uuid: , job_args: )
|
6
|
-
case action
|
7
|
-
when ProconBypassMan::RemotePbmAction::ACTION_CHANGE_PBM_VERSION
|
8
|
-
ProconBypassMan::RemotePbmAction::ChangePbmVersionAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
|
9
|
-
when ProconBypassMan::RemotePbmAction::ACTION_STOP_PBM
|
10
|
-
ProconBypassMan::RemotePbmAction::StopPbmAction.new(pbm_job_uuid: uuid).run!(job_args: {})
|
11
|
-
when ProconBypassMan::RemotePbmAction::ACTION_REBOOT_OS
|
12
|
-
ProconBypassMan::RemotePbmAction::RebootOsAction.new(pbm_job_uuid: uuid).run!(job_args: {})
|
13
|
-
when ProconBypassMan::RemotePbmAction::ACTION_RESTORE_SETTING
|
14
|
-
ProconBypassMan::RemotePbmAction::RestorePbmSettingAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
|
15
|
-
else
|
16
|
-
raise "#{action}は対応していないアクションです"
|
17
|
-
end
|
18
|
-
rescue ProconBypassMan::RemotePbmAction::ActionUnexpectedError => e
|
19
|
-
ProconBypassMan::SendErrorCommand.execute(error: e)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module RemotePbmAction
|
3
|
-
class RebootOsAction < BaseAction
|
4
|
-
|
5
|
-
def action_content(_args)
|
6
|
-
ProconBypassMan.logger.info "execute RebootOsAction!"
|
7
|
-
`reboot`
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def before_action_callback
|
13
|
-
ProconBypassMan::ReportStartRebootJob.perform
|
14
|
-
be_processed
|
15
|
-
end
|
16
|
-
|
17
|
-
def after_action_callback
|
18
|
-
# no-op
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module RemotePbmAction
|
3
|
-
class RestorePbmSettingAction < BaseAction
|
4
|
-
|
5
|
-
def action_content(args: )
|
6
|
-
require "pbmenv"
|
7
|
-
ProconBypassMan.logger.info "execute RestorePbmSettingAction!"
|
8
|
-
setting = args.dig("setting") or raise(ProconBypassMan::RemotePbmAction::NeedPbmVersionError, "settingが必要です, #{args.inspect}")
|
9
|
-
|
10
|
-
# 復元に失敗したら戻せるように退避する
|
11
|
-
FileUtils.copy(
|
12
|
-
ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path,
|
13
|
-
ProconBypassMan.fallback_setting_path,
|
14
|
-
)
|
15
|
-
|
16
|
-
ProconBypassMan::YamlWriter.write(
|
17
|
-
path: ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path,
|
18
|
-
content: setting,
|
19
|
-
)
|
20
|
-
|
21
|
-
hot_reload!
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def before_action_callback
|
27
|
-
be_in_progress
|
28
|
-
end
|
29
|
-
|
30
|
-
def after_action_callback
|
31
|
-
be_processed
|
32
|
-
end
|
33
|
-
|
34
|
-
# @return [void]
|
35
|
-
def hot_reload!
|
36
|
-
Process.kill(:USR2, ProconBypassMan.pid)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module RemotePbmAction
|
3
|
-
class StopPbmAction < BaseAction
|
4
|
-
|
5
|
-
def action_content(_args)
|
6
|
-
ProconBypassMan.logger.info "execute StopPbmAction!"
|
7
|
-
Process.kill("TERM", ProconBypassMan.pid)
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def before_action_callback
|
13
|
-
be_processed
|
14
|
-
end
|
15
|
-
|
16
|
-
def after_action_callback
|
17
|
-
# no-op
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ProconBypassMan
|
4
|
-
module RemotePbmAction
|
5
|
-
require "procon_bypass_man/remote_pbm_action/base_action"
|
6
|
-
require "procon_bypass_man/remote_pbm_action/change_pbm_version_action"
|
7
|
-
require "procon_bypass_man/remote_pbm_action/reboot_os_action"
|
8
|
-
require "procon_bypass_man/remote_pbm_action/stop_pbm_action"
|
9
|
-
require "procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb"
|
10
|
-
require "procon_bypass_man/remote_pbm_action/commands/update_remote_pbm_action_status_command"
|
11
|
-
require "procon_bypass_man/remote_pbm_action/commands/run_remote_pbm_action_dispatch_command"
|
12
|
-
require "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
|
13
|
-
|
14
|
-
ACTION_CHANGE_PBM_VERSION = "change_pbm_version"
|
15
|
-
ACTION_REBOOT_OS = "reboot_os"
|
16
|
-
ACTION_STOP_PBM = "stop_pbm"
|
17
|
-
ACTION_RESTORE_SETTING = "restore_pbm_setting"
|
18
|
-
|
19
|
-
ACTIONS = [
|
20
|
-
ACTION_CHANGE_PBM_VERSION,
|
21
|
-
ACTION_REBOOT_OS,
|
22
|
-
ACTION_STOP_PBM,
|
23
|
-
ACTION_RESTORE_SETTING,
|
24
|
-
]
|
25
|
-
|
26
|
-
STATUS_FAILED = :failed
|
27
|
-
STATUS_IN_PROGRESS = :in_progress
|
28
|
-
STATUS_PROCESSED = :processed
|
29
|
-
|
30
|
-
ACTION_STATUSES = [
|
31
|
-
STATUS_FAILED,
|
32
|
-
STATUS_IN_PROGRESS,
|
33
|
-
STATUS_PROCESSED,
|
34
|
-
]
|
35
|
-
end
|
36
|
-
end
|