procon_bypass_man 0.3.4 → 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 +10 -1
- data/Gemfile.lock +3 -3
- data/README.md +1 -8
- data/Steepfile +0 -1
- data/bin/generate_output_report +18 -0
- data/docs/getting_started.md +13 -9
- data/docs/setting/splatoon3_macro_dasei_cancel.md +7 -0
- data/docs/setting/{splatoon3_rotation_forward_stick.md → splatoon3_rotation_left_stick.md} +1 -1
- 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/jobs/report_warning_job.rb +11 -0
- data/lib/procon_bypass_man/background.rb +2 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +6 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/metadata_loader.rb +27 -0
- data/lib/procon_bypass_man/buttons_setting_configuration/validator.rb +4 -4
- data/lib/procon_bypass_man/bypass/bypass_command.rb +2 -2
- 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/send_warning_command.rb +18 -0
- data/lib/procon_bypass_man/commands.rb +2 -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/procon_bypass_man.gemspec +1 -1
- data/project_template/app.rb +1 -1
- data/project_template/app.rb.erb +1 -1
- data/sig/main.rbs +0 -6
- metadata +30 -23
- 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 -28
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f19608c134a980243f4e45da1a1685367dd4bffc114482682b5d8d6bef03a90
|
4
|
+
data.tar.gz: c0ce801d735e63e5d6a385854ad83abb08fe044342bda63b5d70d2d50b3589f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e84f9b7fa368adc1cbbb8593aca61d2a1a362453a13c5b226912d490c82933d476072f11ecb36226657107aa68b08be734ac19ec8901b56a00deb980d218b9
|
7
|
+
data.tar.gz: 642a6813619dccbb9d28f634bb7bb866ec92a2ed34fac254336562ed462512b1e9eb6ec2672dae17727e9c6790651f4e481e24a9a919dbd87381e4a457c62796
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
+
## [0.3.6] 2023-03-12
|
2
|
+
- プロコンの入力状態をpbm-cloudサーバに送信できるようになりました
|
3
|
+
|
4
|
+
## [0.3.5] - 2023-2-9
|
5
|
+
* 設定ファイルに起動に必要なPBMのバージョンを表記できるようになりました
|
6
|
+
* https://github.com/splaplapla/procon_bypass_man/pull/238
|
7
|
+
* レイヤー変更ボタン(prefix_keys_for_changing_layer)が空欄の時に設定ファイルをエラーが起きないようにしました
|
8
|
+
* PBM-CloudからPBMをアップグレードするときに、古いバージョンを削除するようにしました
|
9
|
+
|
1
10
|
## [0.3.4] - 2022-12-26
|
2
11
|
* 左スティックを1回転するマクロを追加しました
|
3
|
-
* 詳しい設定方法については docs/setting/
|
12
|
+
* 詳しい設定方法については docs/setting/splatoon3_rotation_left_stick.md を参照してください
|
4
13
|
* プログラムの停止時・再読み込み時に時間がかかってた不具合を修正しました
|
5
14
|
|
6
15
|
## [0.3.3.1] - 2022-11-13
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
procon_bypass_man (0.3.
|
4
|
+
procon_bypass_man (0.3.6)
|
5
5
|
action_cable_client
|
6
6
|
blue_green_process (= 0.1.4.2)
|
7
|
-
pbmenv (>= 0.1.
|
7
|
+
pbmenv (>= 0.1.11)
|
8
8
|
sorted_set
|
9
9
|
|
10
10
|
GEM
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
parallel (1.21.0)
|
39
39
|
parser (3.0.3.2)
|
40
40
|
ast (~> 2.4.1)
|
41
|
-
pbmenv (0.1.
|
41
|
+
pbmenv (0.1.11)
|
42
42
|
pry (0.14.1)
|
43
43
|
coderay (~> 1.1)
|
44
44
|
method_source (~> 1.0)
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ https://user-images.githubusercontent.com/1664497/171327108-f12f56a5-fc36-48da-9
|
|
38
38
|
* レイヤーを切り替える方法は?
|
39
39
|
* 設定ファイルに記述している `prefix_keys_for_changing_layer`の後ろにあるキーを同時押しながら、十字キーのどれかを押すことで任意のレイヤーに切り替わります
|
40
40
|
* このツールでできることは?
|
41
|
-
* キーリマップ, 連射,
|
41
|
+
* キーリマップ, 連射, マクロ
|
42
42
|
* リマップは1つのキーを別のキーに割り当てます
|
43
43
|
* 連射中には特定のキーの入力を無視したり、複数のキーをトリガーに連射することができます
|
44
44
|
* どうしてsudoが必要なの?
|
@@ -80,13 +80,6 @@ sudo kill -USR2 `cat ./pbm_pid`
|
|
80
80
|
* githubのreleaseを作成する
|
81
81
|
-->
|
82
82
|
|
83
|
-
## Raspberry Pi4のセットアップを代行します
|
84
|
-
* Raspberry Pi4を開発者である私の家に配送してくれれば、セットアップを代行します。セットアップが終わり次第送り返します
|
85
|
-
* 使い方に関しては、https://pbm-cloud.jiikko.com ですべて完結するので、Linuxの知識は不要です
|
86
|
-
* 何か問題が起きた時はリモートログインでサポート可能です
|
87
|
-
* 希望者はDiscordの `kawagu#7684` にDMを送ってください
|
88
|
-
* お金はかかりません
|
89
|
-
|
90
83
|
## 開発を支援してくれる人を募集しています
|
91
84
|
* https://jiikko.fanbox.cc/
|
92
85
|
* procon_bypassの運営・開発・サーバー費用に充てさせていただきます。また、問い合わせに優先して対応します。
|
data/Steepfile
CHANGED
@@ -40,7 +40,6 @@ target :lib do
|
|
40
40
|
check 'lib/procon_bypass_man/support/on_memory_cache'
|
41
41
|
check 'lib/procon_bypass_man/support/uptime.rb'
|
42
42
|
check 'lib/procon_bypass_man/support/safe_timeout'
|
43
|
-
check 'lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client'
|
44
43
|
check 'lib/procon_bypass_man/support/compress_array'
|
45
44
|
|
46
45
|
signature 'sig'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "procon_bypass_man"
|
5
|
+
require "pry"
|
6
|
+
|
7
|
+
# \x30のみ生成する
|
8
|
+
# Usage:
|
9
|
+
# $ `generate_output_report x zl y` のように、引数にボタン名を渡す
|
10
|
+
|
11
|
+
no_action_binary = ["30f28100800078c77448287509550274ff131029001b0022005a0271ff191028001e00210064027cff1410280020002100000000000000000000000000000000"].pack("H*")
|
12
|
+
user_operation = ProconBypassMan::Procon::UserOperation.new(no_action_binary)
|
13
|
+
|
14
|
+
ARGV.map { |x| x.to_sym }.each do |button|
|
15
|
+
user_operation.press_button(button)
|
16
|
+
end
|
17
|
+
|
18
|
+
puts user_operation.binary.unpack.first
|
data/docs/getting_started.md
CHANGED
@@ -3,17 +3,16 @@
|
|
3
3
|
* [はじめに](#はじめに)
|
4
4
|
* [procon_bypass_manで解決したいこと](#procon_bypass_manで解決したいこと)
|
5
5
|
* [procon_bypass_manでできること](#procon_bypass_manでできること)
|
6
|
-
* [セットアップを代行できます](#セットアップを代行できます)
|
7
6
|
* [セットアップ](#セットアップ)
|
8
7
|
* [ラズベリーパイのセットアップ](#ラズベリーパイのセットアップ)
|
9
8
|
* [procon_bypass_manのインストール](#procon_bypass_manのインストール)
|
10
9
|
* [pbmenvを使う方法](#pbmenvを使う方法)
|
11
10
|
* [pbmenvを使わない方法](#pbmenvを使わない方法)
|
11
|
+
* [RaspberryPiの給電について](#RaspberryPiの給電について)
|
12
12
|
* [普段使いをするためのセットアップ](#普段使いをするためのセットアップ)
|
13
13
|
* [レイヤー](#レイヤー)
|
14
14
|
* [マクロ](#マクロ)
|
15
15
|
* [左スティックの感度調整](#左スティックの感度調整)
|
16
|
-
* [入力表示](#入力表示)
|
17
16
|
* [設定ファイルの書き方](#設定ファイルの書き方)
|
18
17
|
* プラグインの書き方
|
19
18
|
* [設定ファイルの書き方がわからない、エラーが起きるとき](#設定ファイルの書き方がわからない、エラーが起きるとき)
|
@@ -43,15 +42,10 @@
|
|
43
42
|
* [設定方法](/docs/setting/left-analogstick-cap.md)
|
44
43
|
* WEBから設定状態の閲覧・反映
|
45
44
|
* ボタンリマップ
|
45
|
+
<!--
|
46
46
|
* 入力表示
|
47
47
|
* https://github.com/splaplapla/switch-procon-input-viewer
|
48
|
-
|
49
|
-
## セットアップを代行できます
|
50
|
-
* Raspberry Pi4を開発者である私の家に配送してくれれば、セットアップを代行します。セットアップが終わり次第送り返します
|
51
|
-
* 使い方に関しては、https://pbm-cloud.jiikko.com ですべて完結するので、Linuxの知識は不要です
|
52
|
-
* 何か問題が起きた時はリモートログインでサポート可能です
|
53
|
-
* 希望者はDiscordの `kawagu#7684` にDMを送ってください
|
54
|
-
* お金はかかりません
|
48
|
+
-->
|
55
49
|
|
56
50
|
## セットアップ
|
57
51
|
### ラズベリーパイのセットアップ
|
@@ -123,6 +117,14 @@ wget https://raw.githubusercontent.com/jiikko/procon_bypass_man_sample/master/se
|
|
123
117
|
sudo /home/pi/.rbenv/versions/3.0.1/bin/ruby app.rb
|
124
118
|
```
|
125
119
|
|
120
|
+
## RaspberryPiの給電について
|
121
|
+
Raspberry Piの状態によっては、Switchと接続しているときに、Raspberry Piが電力不足になるようで動作が不安定になることがあります。
|
122
|
+
不安定になるようであれば、Switch以外からも給電してみてください。詳細には言及しませんが、主な給電方法には、以下があります。
|
123
|
+
|
124
|
+
* GPIO端子
|
125
|
+
* セルフパワーUSBハブ
|
126
|
+
* PoE
|
127
|
+
|
126
128
|
## 普段使いをするためのセットアップ
|
127
129
|
|
128
130
|
procon_bypass_manを起動するだけでプロコンと接続ができるようになったら、Raspberry Piを起動したときにprocon_bypass_manも自動起動するように設定しましょう。
|
@@ -215,9 +217,11 @@ open_macro :sokuwari, steps: [:toggle_r_for_0_2sec, :toggle_thumbr_for_0_14sec,
|
|
215
217
|
## 左スティックの感度調整
|
216
218
|
[左スティックの感度調整](/docs/setting/left-analogstick-cap.md)
|
217
219
|
|
220
|
+
<!--
|
218
221
|
## 入力表示
|
219
222
|
* 使い方は https://github.com/splaplapla/switch-procon-input-viewer を参照してください。
|
220
223
|
* https://zenn.dev/jiikko/articles/2ef0ccbdfe0fe7 に技術的な解説を書きました
|
224
|
+
-->
|
221
225
|
|
222
226
|
## 設定ファイルの書き方
|
223
227
|
設定ファイルは、ymlフォーマットに埋め込まれたRubyスクリプトで記述します。
|
@@ -3,6 +3,13 @@
|
|
3
3
|
* 本マクロは実験段階で、オプション名などの仕様が変更される可能性が高いです
|
4
4
|
* procon_bypass_man: 0.3.3以上が必要です
|
5
5
|
|
6
|
+
|
7
|
+
|
8
|
+
https://user-images.githubusercontent.com/1664497/210229394-493a7ad4-b4cf-4dfd-87da-2398494e00fd.mp4
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
6
13
|
## 1. install_macro_pluginでマクロを有効化します
|
7
14
|
* `setting.yml` に`install_macro_plugin ProconBypassMan::Plugin::Splatoon3::Macro::DaseiCancel` と書きます
|
8
15
|
* これを記述することで、layer内でmacroを呼び出せるようになります
|
@@ -12,7 +12,7 @@ https://user-images.githubusercontent.com/1664497/205416889-d458668e-ab46-4867-8
|
|
12
12
|
version: 1.0
|
13
13
|
setting: |-
|
14
14
|
prefix_keys_for_changing_layer [:zr, :zl, :l]
|
15
|
-
install_macro_plugin(ProconBypassMan::Plugin::
|
15
|
+
install_macro_plugin(ProconBypassMan::Plugin::Splatoon3::Macro::RotationLeftStick)
|
16
16
|
|
17
17
|
layer :up do
|
18
18
|
macro ProconBypassMan::Plugin::Splatoon3::Macro::RotationLeftStick, if_pressed: [:left]
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ProconBypassMan::PostCompletedRemoteActionJob < ProconBypassMan::BaseJob
|
2
|
+
extend ProconBypassMan::HasExternalApiSetting
|
3
|
+
|
4
|
+
# @param [Symbol] status
|
5
|
+
def self.perform(job_id)
|
6
|
+
ProconBypassMan::RemoteMacroHttpClient.new(
|
7
|
+
path: path,
|
8
|
+
server: api_server,
|
9
|
+
).post(job_id: job_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.path
|
13
|
+
device_id = ProconBypassMan.device_id
|
14
|
+
"/api/devices/#{ProconBypassMan.device_id}/completed_pbm_remote_macro_jobs"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.re_enqueue_if_failed
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ProconBypassMan::ReportInfoLogJob < ProconBypassMan::ReportEventBaseJob
|
2
|
+
extend ProconBypassMan::HasExternalApiSetting
|
3
|
+
|
4
|
+
# @param [String] body
|
5
|
+
def self.perform(body)
|
6
|
+
ProconBypassMan::ReportHttpClient.new(
|
7
|
+
path: path,
|
8
|
+
server: api_server,
|
9
|
+
).post(body: body, event_type: :info)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ProconBypassMan::ReportWarningJob < ProconBypassMan::ReportEventBaseJob
|
2
|
+
extend ProconBypassMan::HasExternalApiSetting
|
3
|
+
|
4
|
+
# @param [String] body
|
5
|
+
def self.perform(body)
|
6
|
+
ProconBypassMan::ReportHttpClient.new(
|
7
|
+
path: path,
|
8
|
+
server: api_server,
|
9
|
+
).post(body: body, event_type: :warn)
|
10
|
+
end
|
11
|
+
end
|
@@ -9,6 +9,8 @@ require "procon_bypass_man/background/jobs/report_reload_config_job"
|
|
9
9
|
require "procon_bypass_man/background/jobs/report_error_reload_config_job"
|
10
10
|
require "procon_bypass_man/background/jobs/report_load_config_job"
|
11
11
|
require "procon_bypass_man/background/jobs/report_error_job"
|
12
|
+
require "procon_bypass_man/background/jobs/report_warning_job"
|
13
|
+
require "procon_bypass_man/background/jobs/report_info_log_job"
|
12
14
|
require "procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job"
|
13
15
|
require "procon_bypass_man/background/jobs/report_procon_performance_measurements_job"
|
14
16
|
require "procon_bypass_man/background/jobs/sync_device_stats_job"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "procon_bypass_man/buttons_setting_configuration/param_normalizer"
|
2
|
+
require "procon_bypass_man/buttons_setting_configuration/metadata_loader"
|
2
3
|
|
3
4
|
module ProconBypassMan
|
4
5
|
class ButtonsSettingConfiguration
|
@@ -9,6 +10,11 @@ module ProconBypassMan
|
|
9
10
|
def self.load(setting_path: )
|
10
11
|
ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path = setting_path
|
11
12
|
|
13
|
+
metadata_loader = ProconBypassMan::ButtonsSettingConfiguration::MetadataLoader.load(setting_path: setting_path)
|
14
|
+
if(Gem::Version.new(metadata_loader.required_pbm_version) >= Gem::Version.new(ProconBypassMan::VERSION))
|
15
|
+
ProconBypassMan::SendErrorCommand.execute(error: '起動中のPBMが設定ファイルのバージョンを満たしていません。設定ファイルが意図した通り動かない可能性があります。PBMのバージョンをあげてください。')
|
16
|
+
end
|
17
|
+
|
12
18
|
ProconBypassMan::ButtonsSettingConfiguration.switch_new_context(:validation) do |new_instance|
|
13
19
|
yaml = YAML.load_file(setting_path) or raise "読み込みに失敗しました"
|
14
20
|
new_instance.instance_eval(yaml["setting"])
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
class ButtonsSettingConfiguration
|
3
|
+
class MetadataLoader
|
4
|
+
EMPTY_VERSION = '0.0.0'
|
5
|
+
|
6
|
+
# @param [String] setting_path
|
7
|
+
# @return [MetadataLoader]
|
8
|
+
def self.load(setting_path: )
|
9
|
+
self.new(setting_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
# @param [String] setting_path
|
13
|
+
def initialize(setting_path)
|
14
|
+
content = File.read(setting_path)
|
15
|
+
if(matched = content.match(/metadata-required_pbm_version: ([\d.]+)/))
|
16
|
+
@required_pbm_version = matched[1]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
def required_pbm_version
|
22
|
+
return EMPTY_VERSION unless defined?(@required_pbm_version)
|
23
|
+
return @required_pbm_version if @required_pbm_version
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -12,7 +12,7 @@ module ProconBypassMan
|
|
12
12
|
def valid?
|
13
13
|
@errors = Hash.new {|h,k| h[k] = [] }
|
14
14
|
|
15
|
-
|
15
|
+
warn_blank_prefix_keys
|
16
16
|
validate_config_of_button_lonely
|
17
17
|
validate_verify_button_existence
|
18
18
|
validate_flip_and_remap_are_hate_each_other
|
@@ -56,10 +56,10 @@ module ProconBypassMan
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
# @return [void]
|
60
|
+
def warn_blank_prefix_keys
|
60
61
|
if @prefix_keys.empty?
|
61
|
-
|
62
|
-
@errors[:prefix_keys] << "prefix_keys_for_changing_layerに値が入っていません。"
|
62
|
+
ProconBypassMan.logger.warn "prefix_keys_for_changing_layerに値が入っていません。"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -65,8 +65,8 @@ class ProconBypassMan::BypassCommand
|
|
65
65
|
process.work
|
66
66
|
|
67
67
|
process_switching_time_before_work = BlueGreenProcess.performance.process_switching_time_before_work
|
68
|
-
if process_switching_time_before_work > 0.
|
69
|
-
ProconBypassMan::
|
68
|
+
if process_switching_time_before_work > 0.2
|
69
|
+
ProconBypassMan::SendWarningCommand.execute(warning: "[PERFORMANCE] BlueGreenProcess.performance.process_switching_time_before_work: #{process_switching_time_before_work}", stdout: false)
|
70
70
|
end
|
71
71
|
|
72
72
|
rescue EOFError => e
|
@@ -47,6 +47,9 @@ class ProconBypassMan::Bypass::ProconToSwitch
|
|
47
47
|
self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary: raw_output)
|
48
48
|
end
|
49
49
|
|
50
|
+
# 後続処理で入力値を取得できるように詰めておく
|
51
|
+
ProconBypassMan::ProconDisplay::Status.instance.current = bypass_value.binary.to_procon_reader.to_hash
|
52
|
+
|
50
53
|
result = measurement.record_write_time do
|
51
54
|
begin
|
52
55
|
ProconBypassMan::Retryable.retryable(tries: 5, on_no_retry: [Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError, Errno::ESHUTDOWN, Errno::ETIMEDOUT]) do
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ProconBypassMan::SendInfoLogCommand
|
2
|
+
# @param [String] message
|
3
|
+
# @return [void]
|
4
|
+
def self.execute(message: , stdout: true)
|
5
|
+
body = message
|
6
|
+
ProconBypassMan.logger.info(body)
|
7
|
+
puts body if stdout
|
8
|
+
|
9
|
+
ProconBypassMan::ReportInfoLogJob.perform(body)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ProconBypassMan::SendWarningCommand
|
2
|
+
# @param [String, Hash, Exception] warning
|
3
|
+
# @return [void]
|
4
|
+
def self.execute(warning: , stdout: true)
|
5
|
+
body =
|
6
|
+
case warning
|
7
|
+
when String, Hash
|
8
|
+
warning
|
9
|
+
else
|
10
|
+
warning.full_message
|
11
|
+
end
|
12
|
+
|
13
|
+
ProconBypassMan.logger.warn body
|
14
|
+
puts body if stdout
|
15
|
+
|
16
|
+
ProconBypassMan::ReportWarningJob.perform(warning)
|
17
|
+
end
|
18
|
+
end
|
@@ -4,3 +4,5 @@ require "procon_bypass_man/commands/write_session_id_command"
|
|
4
4
|
require "procon_bypass_man/commands/write_device_id_command"
|
5
5
|
require "procon_bypass_man/commands/send_reload_config_event_command"
|
6
6
|
require "procon_bypass_man/commands/send_error_command"
|
7
|
+
require "procon_bypass_man/commands/send_warning_command"
|
8
|
+
require "procon_bypass_man/commands/send_info_log_command"
|
@@ -127,17 +127,28 @@ class ProconBypassMan::Procon
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
# remote macro
|
131
|
-
if task = ProconBypassMan::
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
130
|
+
# remote macro or pbm action
|
131
|
+
if task = ProconBypassMan::RemoteAction::TaskQueueInProcess.non_blocking_shift
|
132
|
+
case task.type
|
133
|
+
when ProconBypassMan::RemoteAction::Task::TYPE_MACRO
|
134
|
+
no_op_step = :wait_for_0_3 # マクロの最後に固まって最後の入力をし続けるので、無の状態を最後に注入する
|
135
|
+
BlueGreenProcess::SharedVariable.extend_run_on_this_process = true
|
136
|
+
ProconBypassMan::Procon::MacroRegistry.cleanup_remote_macros!
|
137
|
+
macro_name = task.name || "RemoteMacro-#{task.steps.join}".to_sym
|
138
|
+
task.steps << no_op_step
|
139
|
+
ProconBypassMan::Procon::MacroRegistry.install_plugin(macro_name, steps: task.steps, macro_type: :remote)
|
140
|
+
@@status[:ongoing_macro] = MacroRegistry.load(macro_name, macro_type: :remote) do
|
141
|
+
GC.start # NOTE: extend_run_on_this_process = true するとGCされなくなるので手動で呼び出す
|
142
|
+
ProconBypassMan::PostCompletedRemoteMacroJob.perform_async(task.uuid)
|
143
|
+
end
|
144
|
+
when ProconBypassMan::RemoteAction::Task::TYPE_ACTION
|
145
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::RunRemotePbmJobDispatchCommand.execute(
|
146
|
+
action: task.action,
|
147
|
+
uuid: task.uuid,
|
148
|
+
job_args: task.job_args,
|
149
|
+
)
|
150
|
+
else
|
151
|
+
ProconBypassMan::SendErrorCommand.execute(error: 'unknown type of remote pbm action')
|
141
152
|
end
|
142
153
|
end
|
143
154
|
|
@@ -8,4 +8,3 @@ require "procon_bypass_man/procon_display/server_app"
|
|
8
8
|
require "procon_bypass_man/procon_display/status"
|
9
9
|
require "procon_bypass_man/procon_display/http_response"
|
10
10
|
require "procon_bypass_man/procon_display/http_request"
|
11
|
-
require "procon_bypass_man/procon_display/bypass_hook"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class ProconBypassMan::
|
1
|
+
class ProconBypassMan::RemoteAction::QueueOverProcess
|
2
2
|
extend ProconBypassMan::CanOverProcess
|
3
3
|
|
4
4
|
include Singleton
|
@@ -7,7 +7,7 @@ class ProconBypassMan::RemoteMacro::QueueOverProcess
|
|
7
7
|
|
8
8
|
# @override
|
9
9
|
def self.enable?
|
10
|
-
ProconBypassMan.config.
|
10
|
+
ProconBypassMan.config.enable_remote_action?
|
11
11
|
end
|
12
12
|
|
13
13
|
# @override
|
@@ -1,13 +1,14 @@
|
|
1
|
-
|
1
|
+
# FIXME: BypassProcessSenderみたいにする
|
2
|
+
class ProconBypassMan::RemoteActionReceiver
|
2
3
|
# forkしたプロセスで動かすクラス。sock経由で命令を受け取ってmacoのキューに積んでいく
|
3
4
|
def self.start_with_foreground!
|
4
|
-
return unless ProconBypassMan.config.
|
5
|
+
return unless ProconBypassMan.config.enable_remote_action?
|
5
6
|
|
6
7
|
run
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.start!
|
10
|
-
return unless ProconBypassMan.config.
|
11
|
+
return unless ProconBypassMan.config.enable_remote_action?
|
11
12
|
|
12
13
|
Thread.start do
|
13
14
|
start_with_foreground!
|
@@ -15,7 +16,7 @@ class ProconBypassMan::RemoteMacroReceiver
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def self.run
|
18
|
-
while(task = ProconBypassMan::
|
19
|
+
while(task = ProconBypassMan::RemoteAction::QueueOverProcess.pop)
|
19
20
|
receive(task)
|
20
21
|
end
|
21
22
|
shutdown
|
@@ -24,10 +25,10 @@ class ProconBypassMan::RemoteMacroReceiver
|
|
24
25
|
end
|
25
26
|
|
26
27
|
|
27
|
-
# @param [ProconBypassMan::
|
28
|
+
# @param [ProconBypassMan::RemoteAction::Task] task
|
28
29
|
def self.receive(task)
|
29
|
-
ProconBypassMan.logger.info "[remote macro][receiver] name: #{task.name}, uuid: #{task.uuid}, steps: #{task.steps}"
|
30
|
-
ProconBypassMan::
|
30
|
+
ProconBypassMan.logger.info "[remote macro][receiver] name: #{task.name}, uuid: #{task.uuid}, steps: #{task.steps}, type: #{task.type}"
|
31
|
+
ProconBypassMan::RemoteAction::TaskQueueInProcess.push(task)
|
31
32
|
true
|
32
33
|
end
|
33
34
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# FIXME: RemoteMacroSenderという名前をやめる。BypassProcessSenderみたいにする
|
2
|
+
class ProconBypassMan::RemoteActionSender
|
3
|
+
def self.execute(name: , uuid: , steps: , type: )
|
4
|
+
ProconBypassMan.logger.info "[remote macro][sender] name: #{name}, uuid: #{uuid}, steps: #{steps}, type: #{type}"
|
5
|
+
ProconBypassMan::RemoteAction::QueueOverProcess.push(
|
6
|
+
ProconBypassMan::RemoteAction::Task.new(name, uuid, steps, type)
|
7
|
+
)
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class ActionUnexpectedError < StandardError; end
|
5
|
+
class NeedPbmVersionError < ActionUnexpectedError; end
|
6
|
+
|
7
|
+
class BaseAction
|
8
|
+
attr_accessor :pbm_job_uuid
|
9
|
+
|
10
|
+
# @param [String] pbm_job_uuid
|
11
|
+
def initialize(pbm_job_uuid: )
|
12
|
+
self.pbm_job_uuid = pbm_job_uuid
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [void]
|
16
|
+
def action_content(_args)
|
17
|
+
raise NotImplementedError, nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param [Hash] args
|
21
|
+
# @return [void]
|
22
|
+
def run!(job_args: )
|
23
|
+
before_action_callback
|
24
|
+
action_content(args: job_args)
|
25
|
+
after_action_callback
|
26
|
+
rescue => e
|
27
|
+
be_failed
|
28
|
+
ProconBypassMan::SendErrorCommand.execute(error: e)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @return [void]
|
34
|
+
def before_action_callback; end
|
35
|
+
# @return [void]
|
36
|
+
def after_action_callback; end
|
37
|
+
|
38
|
+
# @return [void]
|
39
|
+
def be_failed
|
40
|
+
ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :failed)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [void]
|
44
|
+
def be_in_progress
|
45
|
+
ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :in_progress)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [void]
|
49
|
+
def be_processed
|
50
|
+
ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :processed)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class ChangePbmVersionAction < BaseAction
|
5
|
+
|
6
|
+
def action_content(args: )
|
7
|
+
require "pbmenv"
|
8
|
+
ProconBypassMan.logger.info "execute ChangePbmVersionAction!"
|
9
|
+
pbm_version = args["pbm_version"] or raise(ProconBypassMan::RemotePbmJob::NeedPbmVersionError, "pbm_versionが必要です, #{args.inspect}")
|
10
|
+
Pbmenv.uninstall(pbm_version) # 途中でシャットダウンしてしまった、とか状態が途中の状態かもしれないので一旦消す
|
11
|
+
Pbmenv.install(pbm_version, enable_pbm_cloud: true)
|
12
|
+
Pbmenv.use(pbm_version)
|
13
|
+
Pbmenv.clean(10)
|
14
|
+
ProconBypassMan.logger.info "#{pbm_version}へアップグレードしました"
|
15
|
+
ProconBypassMan::ReportCompletedUpgradePbmJob.perform
|
16
|
+
`reboot` # symlinkの参照先が変わるのでrebootする必要がある
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def before_action_callback
|
22
|
+
be_processed
|
23
|
+
end
|
24
|
+
|
25
|
+
def after_action_callback
|
26
|
+
# no-op
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class RunRemotePbmJobDispatchCommand
|
5
|
+
# @param [String] action
|
6
|
+
# @param [String] uuid
|
7
|
+
# @return [void]
|
8
|
+
def self.execute(action: , uuid: , job_args: )
|
9
|
+
case action
|
10
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_CHANGE_PBM_VERSION
|
11
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::ChangePbmVersionAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
|
12
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_STOP_PBM
|
13
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::StopPbmJob.new(pbm_job_uuid: uuid).run!(job_args: {})
|
14
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_REBOOT_OS
|
15
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::RebootOsAction.new(pbm_job_uuid: uuid).run!(job_args: {})
|
16
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_RESTORE_SETTING
|
17
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::RestorePbmSettingAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
|
18
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_REPORT_PORCON_STATUS
|
19
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::ReportProconStatusAction.new(pbm_job_uuid: uuid).run!(job_args: {})
|
20
|
+
else
|
21
|
+
raise "#{action}は対応していないアクションです"
|
22
|
+
end
|
23
|
+
rescue ProconBypassMan::RemoteAction::RemotePbmJob::ActionUnexpectedError => e
|
24
|
+
ProconBypassMan::SendErrorCommand.execute(error: e)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|