procon_bypass_man 0.2.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +19 -6
- data/.github/workflows/gitleacks.yml +2 -1
- data/.github/workflows/release.yml +1 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +4 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +16 -1
- data/Gemfile +6 -3
- data/Gemfile.lock +3 -3
- data/README.md +17 -8
- data/Steepfile +0 -1
- data/bin/generate_default_app +10 -0
- data/docs/getting_started.md +98 -25
- data/docs/setup_raspi_by_mitamae.md +44 -2
- data/lib/procon_bypass_man/background/job_performer.rb +1 -2
- data/lib/procon_bypass_man/background/job_queue.rb +50 -0
- data/lib/procon_bypass_man/background/jobs/base_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb +2 -2
- data/lib/procon_bypass_man/background/jobs/concerns/job_performable.rb +16 -0
- data/lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_boot_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_error_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_load_config_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb +43 -0
- data/lib/procon_bypass_man/background/jobs/report_reload_config_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/report_start_reboot_job.rb +1 -1
- data/lib/procon_bypass_man/background/jobs/sync_device_stats_job.rb +1 -1
- data/lib/procon_bypass_man/background.rb +3 -4
- data/lib/procon_bypass_man/bypass/bypass_command.rb +6 -15
- data/lib/procon_bypass_man/bypass/bypass_value.rb +6 -0
- data/lib/procon_bypass_man/bypass/procon_to_switch.rb +107 -0
- data/lib/procon_bypass_man/bypass/switch_to_procon.rb +64 -0
- data/lib/procon_bypass_man/bypass.rb +5 -112
- data/lib/procon_bypass_man/configuration.rb +16 -40
- data/lib/procon_bypass_man/device_connection/output_report_sub_command_table.rb +1 -1
- data/lib/procon_bypass_man/device_connection/procon_setting_overrider.rb +12 -3
- data/lib/procon_bypass_man/procon/macro.rb +1 -1
- data/lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb +17 -0
- data/lib/procon_bypass_man/procon/performance_measurement/measurement_collection.rb +9 -0
- data/lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb +84 -0
- data/lib/procon_bypass_man/procon/performance_measurement/procon_performance_span_transfer_job.rb +8 -0
- data/lib/procon_bypass_man/procon/performance_measurement/queue_over_process.rb +38 -0
- data/lib/procon_bypass_man/procon/performance_measurement/span_queue.rb +42 -0
- data/lib/procon_bypass_man/procon/performance_measurement/span_transfer_buffer.rb +39 -0
- data/lib/procon_bypass_man/procon/performance_measurement.rb +103 -0
- data/lib/procon_bypass_man/procon.rb +2 -1
- data/lib/procon_bypass_man/procon_display/bypass_hook.rb +12 -0
- data/lib/procon_bypass_man/procon_display/http_request.rb +31 -0
- data/lib/procon_bypass_man/procon_display/http_response.rb +23 -0
- data/lib/procon_bypass_man/procon_display/server.rb +33 -0
- data/lib/procon_bypass_man/procon_display/server_app.rb +17 -0
- data/lib/procon_bypass_man/procon_display/status.rb +20 -0
- data/lib/procon_bypass_man/procon_display.rb +11 -0
- data/lib/procon_bypass_man/remote_macro/queue_over_process.rb +26 -44
- data/lib/procon_bypass_man/remote_macro/remote_macro_object.rb +22 -24
- data/lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb +1 -1
- data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +1 -1
- data/lib/procon_bypass_man/remote_macro/task.rb +1 -5
- data/lib/procon_bypass_man/remote_macro/task_queue.rb +6 -10
- data/lib/procon_bypass_man/remote_pbm_action/commands/update_remote_pbm_action_status_command.rb +1 -1
- data/lib/procon_bypass_man/runner.rb +4 -9
- data/lib/procon_bypass_man/scheduler.rb +15 -6
- data/lib/procon_bypass_man/support/callbacks.rb +72 -34
- data/lib/procon_bypass_man/support/can_over_process.rb +60 -0
- data/lib/procon_bypass_man/support/gc.rb +8 -0
- data/lib/procon_bypass_man/support/http_client.rb +9 -6
- data/lib/procon_bypass_man/support/load_agv.rb +20 -0
- data/lib/procon_bypass_man/support/procon_performance_http_client.rb +7 -0
- data/lib/procon_bypass_man/support/retryable.rb +16 -0
- data/lib/procon_bypass_man/support/signal_handler.rb +1 -1
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/client.rb +2 -2
- data/lib/procon_bypass_man/worker.rb +32 -0
- data/lib/procon_bypass_man.rb +41 -10
- data/procon_bypass_man.gemspec +1 -1
- data/project_template/README.md +0 -5
- data/project_template/app.rb +21 -11
- data/project_template/app.rb.erb +62 -0
- data/project_template/lib/app_generator.rb +31 -0
- data/project_template/web.rb +1 -1
- data/sig/main.rbs +10 -52
- data/tmp/.keep +0 -0
- metadata +34 -10
- data/lib/procon_bypass_man/background/job_runner.rb +0 -45
- data/lib/procon_bypass_man/background/jobs/concerns/has_internal_api_setting.rb +0 -5
- data/lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb +0 -16
- data/lib/procon_bypass_man/background/jobs/report_pressed_buttons_job.rb +0 -15
- data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +0 -44
- data/lib/procon_bypass_man/io_monitor.rb +0 -108
- data/lib/procon_bypass_man/support/server_pool.rb +0 -46
data/lib/procon_bypass_man.rb
CHANGED
@@ -12,8 +12,6 @@ require "resolv-replace"
|
|
12
12
|
require "pbmenv"
|
13
13
|
|
14
14
|
require_relative "procon_bypass_man/version"
|
15
|
-
require_relative "procon_bypass_man/remote_pbm_action"
|
16
|
-
require_relative "procon_bypass_man/remote_macro"
|
17
15
|
|
18
16
|
require_relative "procon_bypass_man/device_connection"
|
19
17
|
require_relative "procon_bypass_man/support/usb_device_controller"
|
@@ -26,16 +24,21 @@ require_relative "procon_bypass_man/support/yaml_writer"
|
|
26
24
|
require_relative "procon_bypass_man/support/safe_timeout"
|
27
25
|
require_relative "procon_bypass_man/support/compress_array"
|
28
26
|
require_relative "procon_bypass_man/support/uptime"
|
27
|
+
require_relative "procon_bypass_man/support/load_agv"
|
29
28
|
require_relative "procon_bypass_man/support/on_memory_cache"
|
30
29
|
require_relative "procon_bypass_man/support/http_client"
|
31
30
|
require_relative "procon_bypass_man/support/report_http_client"
|
32
31
|
require_relative "procon_bypass_man/support/remote_macro_http_client"
|
33
32
|
require_relative "procon_bypass_man/support/update_remote_pbm_action_status_http_client"
|
34
33
|
require_relative "procon_bypass_man/support/send_device_stats_http_client"
|
35
|
-
require_relative "procon_bypass_man/support/
|
34
|
+
require_relative "procon_bypass_man/support/procon_performance_http_client"
|
36
35
|
require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
|
37
36
|
require_relative "procon_bypass_man/support/never_exit_accidentally"
|
38
37
|
require_relative "procon_bypass_man/support/cycle_sleep"
|
38
|
+
require_relative "procon_bypass_man/support/can_over_process"
|
39
|
+
require_relative "procon_bypass_man/support/gc"
|
40
|
+
require_relative "procon_bypass_man/support/retryable"
|
41
|
+
require_relative "procon_bypass_man/procon_display"
|
39
42
|
require_relative "procon_bypass_man/background"
|
40
43
|
require_relative "procon_bypass_man/commands"
|
41
44
|
require_relative "procon_bypass_man/bypass"
|
@@ -52,10 +55,14 @@ require_relative "procon_bypass_man/procon/analog_stick_manipulator"
|
|
52
55
|
require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
|
53
56
|
require_relative "procon_bypass_man/scheduler"
|
54
57
|
require_relative "procon_bypass_man/plugins"
|
58
|
+
require_relative "procon_bypass_man/worker"
|
55
59
|
require_relative "procon_bypass_man/websocket/client"
|
56
60
|
require_relative "procon_bypass_man/websocket/watchdog"
|
57
61
|
require_relative "procon_bypass_man/websocket/forever"
|
58
62
|
|
63
|
+
require_relative "procon_bypass_man/remote_pbm_action"
|
64
|
+
require_relative "procon_bypass_man/remote_macro"
|
65
|
+
|
59
66
|
STDOUT.sync = true
|
60
67
|
Thread.abort_on_exception = true
|
61
68
|
|
@@ -66,11 +73,18 @@ module ProconBypassMan
|
|
66
73
|
class CouldNotLoadConfigError < StandardError; end
|
67
74
|
class NotFoundProconError < StandardError; end
|
68
75
|
|
76
|
+
class InterruptForRestart < StandardError; end
|
77
|
+
|
78
|
+
class << self
|
79
|
+
attr_accessor :worker
|
80
|
+
end
|
81
|
+
|
69
82
|
# @return [void]
|
70
83
|
def self.run(setting_path: nil)
|
71
84
|
ProconBypassMan::PrintMessageCommand.execute(text: "PBMを起動しています")
|
72
85
|
initialize_pbm
|
73
86
|
|
87
|
+
# 設定ファイルの読み込み
|
74
88
|
begin
|
75
89
|
ProconBypassMan::ButtonsSettingConfiguration::Loader.load(setting_path: setting_path)
|
76
90
|
rescue ProconBypassMan::CouldNotLoadConfigError
|
@@ -83,6 +97,7 @@ module ProconBypassMan
|
|
83
97
|
return
|
84
98
|
end
|
85
99
|
|
100
|
+
# デバイスの接続フェーズ
|
86
101
|
begin
|
87
102
|
gadget, procon = ProconBypassMan::DeviceConnection::Command.execute!
|
88
103
|
rescue ProconBypassMan::DeviceConnection::NotFoundProconError
|
@@ -94,7 +109,7 @@ module ProconBypassMan
|
|
94
109
|
end
|
95
110
|
return
|
96
111
|
rescue ProconBypassMan::DeviceConnection::TimeoutError
|
97
|
-
ProconBypassMan::SendErrorCommand.execute(error: "
|
112
|
+
ProconBypassMan::SendErrorCommand.execute(error: "接続に失敗しました。プロコンとRaspberry Piのケーブルを差し直して、再実行してください。\n改善しない場合は、app.logの中身を添えて不具合報告をお願いします。")
|
98
113
|
ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping!
|
99
114
|
%w(TERM INT).each do |sig|
|
100
115
|
Kernel.trap(sig) { exit 0 }
|
@@ -130,33 +145,49 @@ module ProconBypassMan
|
|
130
145
|
ProconBypassMan::Procon::ModeRegistry.reset!
|
131
146
|
ProconBypassMan::Procon.reset!
|
132
147
|
ProconBypassMan::ButtonsSettingConfiguration.instance.reset!
|
133
|
-
ProconBypassMan::IOMonitor.reset!
|
134
148
|
end
|
135
149
|
|
136
150
|
# @return [void]
|
137
151
|
def self.initialize_pbm
|
138
|
-
|
139
|
-
ProconBypassMan::Background::
|
152
|
+
`renice -n 20 -p #{$$}`
|
153
|
+
ProconBypassMan::Background::JobQueue.start!
|
140
154
|
ProconBypassMan::Websocket::Client.start!
|
141
|
-
ProconBypassMan::
|
155
|
+
# TODO ProconBypassMan::DrbObjects.start_all! みたいな感じで書きたい
|
156
|
+
ProconBypassMan::RemoteMacro::QueueOverProcess.start!
|
157
|
+
ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.start!
|
158
|
+
ProconBypassMan::Scheduler.start!
|
142
159
|
|
143
160
|
ProconBypassMan::WriteDeviceIdCommand.execute
|
144
161
|
ProconBypassMan::WriteSessionIdCommand.execute
|
145
|
-
`renice -n -20 -p #{$$}`
|
146
162
|
File.write(pid_path, $$)
|
147
163
|
ProconBypassMan::DeviceStatus.change_to_running!
|
148
164
|
end
|
149
165
|
|
166
|
+
# @return [void]
|
150
167
|
def self.ready_pbm
|
151
168
|
ProconBypassMan::PrintBootMessageCommand.execute
|
152
169
|
ProconBypassMan::ReportLoadConfigJob.perform_async(ProconBypassMan.config.raw_setting)
|
170
|
+
|
171
|
+
self.worker = ProconBypassMan::Worker.run
|
172
|
+
end
|
173
|
+
|
174
|
+
# @return [void]
|
175
|
+
def self.after_fork_on_bypass_process
|
176
|
+
`renice -n -20 -p #{$$}`
|
177
|
+
::GC.start
|
178
|
+
DRb.start_service if defined?(DRb)
|
179
|
+
ProconBypassMan::RemoteMacroReceiver.start!
|
180
|
+
ProconBypassMan::ProconDisplay::Server.start!
|
153
181
|
end
|
154
182
|
|
155
183
|
# @return [void]
|
156
184
|
def self.terminate_pbm
|
157
185
|
FileUtils.rm_rf(ProconBypassMan.pid_path)
|
158
186
|
FileUtils.rm_rf(ProconBypassMan.digest_path)
|
159
|
-
ProconBypassMan::
|
187
|
+
ProconBypassMan::Background::JobQueue.shutdown
|
188
|
+
ProconBypassMan::RemoteMacro::QueueOverProcess.shutdown
|
189
|
+
ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.shutdown
|
190
|
+
self.worker&.shutdown
|
160
191
|
end
|
161
192
|
|
162
193
|
# @return [void]
|
data/procon_bypass_man.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/splaplapla/procon_bypass_man"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
data/project_template/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Project Template
|
2
2
|
* これらは https://github.com/splaplapla/pbmenv がinstallするときに配備するファイルです
|
3
|
-
* pbm_webはオプショナルです
|
4
3
|
|
5
4
|
## systemdを使ってサービスに登録する方法
|
6
5
|
systemctl enableした後は、次回のOS起動時にserviceも自動起動します
|
@@ -8,13 +7,9 @@ systemctl enableした後は、次回のOS起動時にserviceも自動起動し
|
|
8
7
|
* pbm
|
9
8
|
* sudo systemctl link /usr/share/pbm/current/systemd_units/pbm.service
|
10
9
|
* sudo systemctl enable pbm.service
|
11
|
-
* pbm_web
|
12
|
-
* sudo systemctl link /usr/share/pbm/current/systemd_units/pbm_web.service
|
13
|
-
* sudo systemctl enable pbm_web.service
|
14
10
|
|
15
11
|
## systemdを使ってサービスから解除する方法
|
16
12
|
* sudo systemctl disable pbm.service
|
17
|
-
* sudo systemctl disable pbm_web.service
|
18
13
|
|
19
14
|
### CheatSheet
|
20
15
|
* systemctl daemon-reload
|
data/project_template/app.rb
CHANGED
@@ -2,31 +2,44 @@
|
|
2
2
|
|
3
3
|
require 'bundler/inline'
|
4
4
|
|
5
|
+
retry_count_on_git_command_error = 0
|
5
6
|
begin
|
7
|
+
if retry_count_on_git_command_error > 10
|
8
|
+
STDOUT.puts "Stopped the procon_bypass_man program because could not download any source codes."
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
6
12
|
gemfile do
|
7
13
|
source 'https://rubygems.org'
|
8
14
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
9
|
-
gem 'procon_bypass_man', '0.2.
|
15
|
+
gem 'procon_bypass_man', '0.2.3'
|
10
16
|
end
|
11
17
|
rescue Bundler::Source::Git::GitCommandError => e
|
18
|
+
retry_count_on_git_command_error = retry_count_on_git_command_error + 1
|
19
|
+
sleep(5) # サービスの起動順によっては、まだoffline状態なので待機する
|
20
|
+
|
12
21
|
# install中に強制終了するとgitの管理ファイルが不正状態になり、次のエラーが起きるので発生したらcache directoryを削除する
|
13
22
|
#"Git error: command `git fetch --force --quiet --tags https://github.com/splaplapla/procon_bypass_man refs/heads/\\*:refs/heads/\\*` in directory /home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af has failed.\n\nIf this error persists you could try removing the cache directory '/home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af'"
|
14
|
-
if /try removing the cache directory '([^']+)'/ =~ e.message
|
23
|
+
if /try removing the cache directory '([^']+)'/ =~ e.message && $1&.start_with?('/home/pi/.rbenv')
|
24
|
+
require 'fileutils'
|
15
25
|
FileUtils.rm_rf($1)
|
16
|
-
|
26
|
+
STDOUT.puts "Deleted #{$1}"
|
17
27
|
end
|
28
|
+
|
29
|
+
retry
|
18
30
|
end
|
19
31
|
|
20
32
|
ProconBypassMan.configure do |config|
|
21
33
|
config.root = File.expand_path(__dir__)
|
22
|
-
config.logger = Logger.new("#{ProconBypassMan.root}/app.log",
|
34
|
+
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 1, 1024 * 1024 * 1)
|
23
35
|
config.logger.level = :debug
|
24
36
|
|
25
37
|
# バイパスするログを全部app.logに流すか
|
26
38
|
config.verbose_bypass_log = false
|
27
39
|
|
28
|
-
# webからProconBypassManを操作できるweb
|
29
|
-
#
|
40
|
+
# webからProconBypassManを操作できるwebサービスと連携します
|
41
|
+
# 連携中はエラーログ、パフォーマンスに関するメトリクスを送信します
|
42
|
+
# config.api_servers = 'https://pbm-cloud.herokuapp.com'
|
30
43
|
|
31
44
|
# エラーが起きたらerror.logに書き込みます
|
32
45
|
config.enable_critical_error_logging = true
|
@@ -34,14 +47,11 @@ ProconBypassMan.configure do |config|
|
|
34
47
|
# pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
|
35
48
|
config.never_exit_accidentally = true
|
36
49
|
|
37
|
-
# 毎秒行ったIOをログに出力するか
|
38
|
-
config.io_monitor_logging = false
|
39
|
-
|
40
50
|
# 接続に成功したらコントローラーのHOME LEDを光らせるか
|
41
51
|
config.enable_home_led_on_connect = true
|
42
52
|
|
43
|
-
# 操作が高頻度で固まるときは、 gadget_to_procon_interval
|
44
|
-
config.bypass_mode = { mode: :normal, gadget_to_procon_interval:
|
53
|
+
# 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値を大きくしてください
|
54
|
+
config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 10 }
|
45
55
|
end
|
46
56
|
|
47
57
|
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/inline'
|
4
|
+
|
5
|
+
retry_count_on_git_command_error = 0
|
6
|
+
begin
|
7
|
+
if retry_count_on_git_command_error > 10
|
8
|
+
STDOUT.puts "Stopped the procon_bypass_man program because could not download any source codes."
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
|
12
|
+
gemfile do
|
13
|
+
source 'https://rubygems.org'
|
14
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
15
|
+
gem 'procon_bypass_man', '0.2.3'
|
16
|
+
end
|
17
|
+
rescue Bundler::Source::Git::GitCommandError => e
|
18
|
+
retry_count_on_git_command_error = retry_count_on_git_command_error + 1
|
19
|
+
sleep(5) # サービスの起動順によっては、まだoffline状態なので待機する
|
20
|
+
|
21
|
+
# install中に強制終了するとgitの管理ファイルが不正状態になり、次のエラーが起きるので発生したらcache directoryを削除する
|
22
|
+
#"Git error: command `git fetch --force --quiet --tags https://github.com/splaplapla/procon_bypass_man refs/heads/\\*:refs/heads/\\*` in directory /home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af has failed.\n\nIf this error persists you could try removing the cache directory '/home/pi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/cache/bundler/git/procon_bypass_man-ae4c9016d76b667658c8ba66f3bbd2eebf2656af'"
|
23
|
+
if /try removing the cache directory '([^']+)'/ =~ e.message && $1&.start_with?('/home/pi/.rbenv')
|
24
|
+
require 'fileutils'
|
25
|
+
FileUtils.rm_rf($1)
|
26
|
+
STDOUT.puts "Deleted #{$1}"
|
27
|
+
end
|
28
|
+
|
29
|
+
retry
|
30
|
+
end
|
31
|
+
|
32
|
+
ProconBypassMan.configure do |config|
|
33
|
+
config.root = File.expand_path(__dir__)
|
34
|
+
config.logger = Logger.new("#{ProconBypassMan.root}/app.log", 1, 1024 * 1024 * 1)
|
35
|
+
config.logger.level = :debug
|
36
|
+
|
37
|
+
# バイパスするログを全部app.logに流すか
|
38
|
+
config.verbose_bypass_log = false
|
39
|
+
|
40
|
+
# webからProconBypassManを操作できるwebサービスと連携します
|
41
|
+
# 連携中はエラーログ、パフォーマンスに関するメトリクスを送信します
|
42
|
+
<%- api_server_config = "config.api_servers = 'https://pbm-cloud.herokuapp.com'" -%>
|
43
|
+
<%- if enable_integration_with_pbm_cloud -%>
|
44
|
+
<%= api_server_config %>
|
45
|
+
<%- else -%>
|
46
|
+
<%= "# #{api_server_config}" %>
|
47
|
+
<%- end -%>
|
48
|
+
|
49
|
+
# エラーが起きたらerror.logに書き込みます
|
50
|
+
config.enable_critical_error_logging = true
|
51
|
+
|
52
|
+
# pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
|
53
|
+
config.never_exit_accidentally = true
|
54
|
+
|
55
|
+
# 接続に成功したらコントローラーのHOME LEDを光らせるか
|
56
|
+
config.enable_home_led_on_connect = true
|
57
|
+
|
58
|
+
# 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値を大きくしてください
|
59
|
+
config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 10 }
|
60
|
+
end
|
61
|
+
|
62
|
+
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
# NOTE pbmenvで参照しているクラス
|
4
|
+
# 後方互換を維持するために、パラメータの削除・必須をしてはいけない
|
5
|
+
class AppGenerator
|
6
|
+
attr_reader :prefix_path
|
7
|
+
|
8
|
+
# @param [String] prefix_path
|
9
|
+
# @param [Boolean] enable_integration_with_pbm_cloud
|
10
|
+
def initialize(prefix_path: , enable_integration_with_pbm_cloud: )
|
11
|
+
@prefix_path = prefix_path
|
12
|
+
@enable_integration_with_pbm_cloud = enable_integration_with_pbm_cloud
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate
|
16
|
+
erb = File.read(template_path)
|
17
|
+
enable_integration_with_pbm_cloud = @enable_integration_with_pbm_cloud
|
18
|
+
app_rb = ERB.new(erb, nil, '-').result(binding)
|
19
|
+
File.write(output_path, app_rb)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def template_path
|
25
|
+
File.join(prefix_path, "app.rb.erb")
|
26
|
+
end
|
27
|
+
|
28
|
+
def output_path
|
29
|
+
File.join(prefix_path, "app.rb")
|
30
|
+
end
|
31
|
+
end
|
data/project_template/web.rb
CHANGED
@@ -10,7 +10,7 @@ end
|
|
10
10
|
|
11
11
|
ProconBypassMan::Web.configure do |config|
|
12
12
|
config.root = File.expand_path(__dir__)
|
13
|
-
config.logger = Logger.new("#{ProconBypassMan::Web.root}/web.log", 1, 1024 * 1024 *
|
13
|
+
config.logger = Logger.new("#{ProconBypassMan::Web.root}/web.log", 1, 1024 * 1024 * 1)
|
14
14
|
end
|
15
15
|
|
16
16
|
ProconBypassMan::Web::Server.start
|
data/sig/main.rbs
CHANGED
@@ -174,6 +174,8 @@ class ProconBypassMan::Configuration
|
|
174
174
|
|
175
175
|
def pid_path: () -> String
|
176
176
|
|
177
|
+
def worker_pid_path: () -> String
|
178
|
+
|
177
179
|
def digest_path: () -> String
|
178
180
|
|
179
181
|
def cache: () -> ProconBypassMan::OnMemoryCache
|
@@ -186,7 +188,6 @@ class ProconBypassMan::Configuration
|
|
186
188
|
attr_reader api_server: untyped
|
187
189
|
attr_reader api_servers: untyped
|
188
190
|
attr_writer never_exit_accidentally: bool
|
189
|
-
attr_writer io_monitor_logging: bool
|
190
191
|
|
191
192
|
attr_accessor enable_critical_error_logging: bool
|
192
193
|
|
@@ -213,9 +214,13 @@ class ProconBypassMan::Configuration
|
|
213
214
|
|
214
215
|
def enable_ws?: () -> bool
|
215
216
|
|
216
|
-
def
|
217
|
+
def has_api_server?: () -> bool
|
218
|
+
|
219
|
+
def enable_procon_performance_measurement?: () -> bool
|
217
220
|
|
218
|
-
def
|
221
|
+
def server: () -> untyped
|
222
|
+
|
223
|
+
def internal_server: () -> untyped
|
219
224
|
|
220
225
|
def internal_servers: () -> ::Array[string | nil]
|
221
226
|
|
@@ -226,8 +231,6 @@ class ProconBypassMan::Configuration
|
|
226
231
|
def verbose_bypass_log: () -> bool
|
227
232
|
|
228
233
|
def never_exit_accidentally: () -> bool
|
229
|
-
|
230
|
-
def io_monitor_logging: () -> bool
|
231
234
|
end
|
232
235
|
|
233
236
|
|
@@ -274,35 +277,6 @@ class ProconBypassMan::DeviceConnector
|
|
274
277
|
def init_devices: () -> untyped
|
275
278
|
end
|
276
279
|
|
277
|
-
module ProconBypassMan
|
278
|
-
class Counter
|
279
|
-
attr_accessor label: untyped
|
280
|
-
|
281
|
-
attr_accessor table: untyped
|
282
|
-
|
283
|
-
attr_accessor previous_table: untyped
|
284
|
-
|
285
|
-
def initialize: (label: untyped label) -> untyped
|
286
|
-
|
287
|
-
# アクティブなバケットは1つだけ
|
288
|
-
def record: (untyped event_name) -> untyped
|
289
|
-
|
290
|
-
def formated_previous_table: () -> ::String
|
291
|
-
end
|
292
|
-
|
293
|
-
module IOMonitor
|
294
|
-
def self.new: (label: untyped label) -> untyped
|
295
|
-
|
296
|
-
# @return [Array<Counter>]
|
297
|
-
def self.targets: () -> untyped
|
298
|
-
|
299
|
-
# ここで集計する
|
300
|
-
def self.start!: () -> untyped
|
301
|
-
|
302
|
-
def self.reset!: () -> untyped
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
280
|
class ProconBypassMan::Processor
|
307
281
|
# @return [String] binary
|
308
282
|
def initialize: (untyped binary) -> untyped
|
@@ -598,11 +572,11 @@ end
|
|
598
572
|
|
599
573
|
module ProconBypassMan
|
600
574
|
class HttpClient
|
601
|
-
@
|
575
|
+
@server: untyped
|
602
576
|
@uri: ::URI
|
603
577
|
@retry_on_connection_error: false
|
604
578
|
|
605
|
-
def initialize: (path: String,
|
579
|
+
def initialize: (path: String, server: untyped, ?retry_on_connection_error: false) -> void
|
606
580
|
def get: -> nil
|
607
581
|
def post: (request_body: untyped) -> nil
|
608
582
|
def put: (request_body: untyped) -> nil
|
@@ -645,22 +619,6 @@ module ProconBypassMan
|
|
645
619
|
end
|
646
620
|
end
|
647
621
|
|
648
|
-
module ProconBypassMan
|
649
|
-
class ServerPool
|
650
|
-
@servers: Array[String]
|
651
|
-
@index: Integer?
|
652
|
-
|
653
|
-
def initialize: (servers: Array[String]) -> void
|
654
|
-
def pick: -> String?
|
655
|
-
def server: -> String?
|
656
|
-
def next!: -> nil
|
657
|
-
|
658
|
-
private
|
659
|
-
def reset: -> Integer
|
660
|
-
def inc_index: -> Integer
|
661
|
-
end
|
662
|
-
end
|
663
|
-
|
664
622
|
module ProconBypassMan
|
665
623
|
class CompressArray
|
666
624
|
@array: [String]
|
data/tmp/.keep
ADDED
File without changes
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pbmenv
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- Steepfile
|
77
77
|
- bin/console
|
78
78
|
- bin/dev_api_server.rb
|
79
|
+
- bin/generate_default_app
|
79
80
|
- bin/setup
|
80
81
|
- docs/getting_started.md
|
81
82
|
- docs/how_to_connect_procon.md
|
@@ -93,11 +94,10 @@ files:
|
|
93
94
|
- lib/procon_bypass_man.rb
|
94
95
|
- lib/procon_bypass_man/background.rb
|
95
96
|
- lib/procon_bypass_man/background/job_performer.rb
|
96
|
-
- lib/procon_bypass_man/background/
|
97
|
+
- lib/procon_bypass_man/background/job_queue.rb
|
97
98
|
- lib/procon_bypass_man/background/jobs/base_job.rb
|
98
99
|
- lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
|
99
|
-
- lib/procon_bypass_man/background/jobs/concerns/
|
100
|
-
- lib/procon_bypass_man/background/jobs/concerns/job_runnable.rb
|
100
|
+
- lib/procon_bypass_man/background/jobs/concerns/job_performable.rb
|
101
101
|
- lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb
|
102
102
|
- lib/procon_bypass_man/background/jobs/report_boot_job.rb
|
103
103
|
- lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
|
@@ -105,7 +105,7 @@ files:
|
|
105
105
|
- lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb
|
106
106
|
- lib/procon_bypass_man/background/jobs/report_event_base_job.rb
|
107
107
|
- lib/procon_bypass_man/background/jobs/report_load_config_job.rb
|
108
|
-
- lib/procon_bypass_man/background/jobs/
|
108
|
+
- lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb
|
109
109
|
- lib/procon_bypass_man/background/jobs/report_reload_config_job.rb
|
110
110
|
- lib/procon_bypass_man/background/jobs/report_start_reboot_job.rb
|
111
111
|
- lib/procon_bypass_man/background/jobs/sync_device_stats_job.rb
|
@@ -124,7 +124,9 @@ files:
|
|
124
124
|
- lib/procon_bypass_man/buttons_setting_configuration/validator.rb
|
125
125
|
- lib/procon_bypass_man/bypass.rb
|
126
126
|
- lib/procon_bypass_man/bypass/bypass_command.rb
|
127
|
-
- lib/procon_bypass_man/bypass/
|
127
|
+
- lib/procon_bypass_man/bypass/bypass_value.rb
|
128
|
+
- lib/procon_bypass_man/bypass/procon_to_switch.rb
|
129
|
+
- lib/procon_bypass_man/bypass/switch_to_procon.rb
|
128
130
|
- lib/procon_bypass_man/commands.rb
|
129
131
|
- lib/procon_bypass_man/commands/print_boot_message_command.rb
|
130
132
|
- lib/procon_bypass_man/commands/print_message_command.rb
|
@@ -145,7 +147,6 @@ files:
|
|
145
147
|
- lib/procon_bypass_man/device_connection/spoofing_output_report_watcher.rb
|
146
148
|
- lib/procon_bypass_man/device_model.rb
|
147
149
|
- lib/procon_bypass_man/device_status.rb
|
148
|
-
- lib/procon_bypass_man/io_monitor.rb
|
149
150
|
- lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb
|
150
151
|
- lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb
|
151
152
|
- lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb
|
@@ -170,6 +171,14 @@ files:
|
|
170
171
|
- lib/procon_bypass_man/procon/macro_plugin_map.rb
|
171
172
|
- lib/procon_bypass_man/procon/macro_registry.rb
|
172
173
|
- lib/procon_bypass_man/procon/mode_registry.rb
|
174
|
+
- lib/procon_bypass_man/procon/performance_measurement.rb
|
175
|
+
- lib/procon_bypass_man/procon/performance_measurement/last_bypass_at.rb
|
176
|
+
- lib/procon_bypass_man/procon/performance_measurement/measurement_collection.rb
|
177
|
+
- lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb
|
178
|
+
- lib/procon_bypass_man/procon/performance_measurement/procon_performance_span_transfer_job.rb
|
179
|
+
- lib/procon_bypass_man/procon/performance_measurement/queue_over_process.rb
|
180
|
+
- lib/procon_bypass_man/procon/performance_measurement/span_queue.rb
|
181
|
+
- lib/procon_bypass_man/procon/performance_measurement/span_transfer_buffer.rb
|
173
182
|
- lib/procon_bypass_man/procon/press_button_aware.rb
|
174
183
|
- lib/procon_bypass_man/procon/suppress_rumble.rb
|
175
184
|
- lib/procon_bypass_man/procon/user_operation.rb
|
@@ -184,6 +193,13 @@ files:
|
|
184
193
|
- lib/procon_bypass_man/procon/value_objects/bypass_mode.rb
|
185
194
|
- lib/procon_bypass_man/procon/value_objects/procon_reader.rb
|
186
195
|
- lib/procon_bypass_man/procon/value_objects/rumble_binary.rb
|
196
|
+
- lib/procon_bypass_man/procon_display.rb
|
197
|
+
- lib/procon_bypass_man/procon_display/bypass_hook.rb
|
198
|
+
- lib/procon_bypass_man/procon_display/http_request.rb
|
199
|
+
- lib/procon_bypass_man/procon_display/http_response.rb
|
200
|
+
- lib/procon_bypass_man/procon_display/server.rb
|
201
|
+
- lib/procon_bypass_man/procon_display/server_app.rb
|
202
|
+
- lib/procon_bypass_man/procon_display/status.rb
|
187
203
|
- lib/procon_bypass_man/remote_macro.rb
|
188
204
|
- lib/procon_bypass_man/remote_macro/queue_over_process.rb
|
189
205
|
- lib/procon_bypass_man/remote_macro/remote_macro_object.rb
|
@@ -204,18 +220,22 @@ files:
|
|
204
220
|
- lib/procon_bypass_man/scheduler.rb
|
205
221
|
- lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb
|
206
222
|
- lib/procon_bypass_man/support/callbacks.rb
|
223
|
+
- lib/procon_bypass_man/support/can_over_process.rb
|
207
224
|
- lib/procon_bypass_man/support/compress_array.rb
|
208
225
|
- lib/procon_bypass_man/support/cycle_sleep.rb
|
209
226
|
- lib/procon_bypass_man/support/device_mouse_finder.rb
|
210
227
|
- lib/procon_bypass_man/support/device_procon_finder.rb
|
228
|
+
- lib/procon_bypass_man/support/gc.rb
|
211
229
|
- lib/procon_bypass_man/support/http_client.rb
|
230
|
+
- lib/procon_bypass_man/support/load_agv.rb
|
212
231
|
- lib/procon_bypass_man/support/never_exit_accidentally.rb
|
213
232
|
- lib/procon_bypass_man/support/on_memory_cache.rb
|
233
|
+
- lib/procon_bypass_man/support/procon_performance_http_client.rb
|
214
234
|
- lib/procon_bypass_man/support/remote_macro_http_client.rb
|
215
235
|
- lib/procon_bypass_man/support/report_http_client.rb
|
236
|
+
- lib/procon_bypass_man/support/retryable.rb
|
216
237
|
- lib/procon_bypass_man/support/safe_timeout.rb
|
217
238
|
- lib/procon_bypass_man/support/send_device_stats_http_client.rb
|
218
|
-
- lib/procon_bypass_man/support/server_pool.rb
|
219
239
|
- lib/procon_bypass_man/support/signal_handler.rb
|
220
240
|
- lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
|
221
241
|
- lib/procon_bypass_man/support/uptime.rb
|
@@ -226,9 +246,12 @@ files:
|
|
226
246
|
- lib/procon_bypass_man/websocket/client.rb
|
227
247
|
- lib/procon_bypass_man/websocket/forever.rb
|
228
248
|
- lib/procon_bypass_man/websocket/watchdog.rb
|
249
|
+
- lib/procon_bypass_man/worker.rb
|
229
250
|
- procon_bypass_man.gemspec
|
230
251
|
- project_template/README.md
|
231
252
|
- project_template/app.rb
|
253
|
+
- project_template/app.rb.erb
|
254
|
+
- project_template/lib/app_generator.rb
|
232
255
|
- project_template/setting.yml
|
233
256
|
- project_template/systemd_units/pbm.service
|
234
257
|
- project_template/systemd_units/pbm_web.service
|
@@ -236,6 +259,7 @@ files:
|
|
236
259
|
- sig/README.md
|
237
260
|
- sig/main.rbs
|
238
261
|
- sig/on_memory_cache.rbs
|
262
|
+
- tmp/.keep
|
239
263
|
homepage: https://github.com/splaplapla/procon_bypass_man
|
240
264
|
licenses:
|
241
265
|
- MIT
|
@@ -251,7 +275,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
275
|
requirements:
|
252
276
|
- - ">="
|
253
277
|
- !ruby/object:Gem::Version
|
254
|
-
version:
|
278
|
+
version: 2.5.0
|
255
279
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
280
|
requirements:
|
257
281
|
- - ">="
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module Background
|
3
|
-
class JobRunner
|
4
|
-
MAX_QUEUE_SIZE = 100
|
5
|
-
|
6
|
-
def self.start!
|
7
|
-
new.start!
|
8
|
-
end
|
9
|
-
|
10
|
-
# for test
|
11
|
-
def stop!
|
12
|
-
return unless defined?(@thread)
|
13
|
-
@thread.kill
|
14
|
-
end
|
15
|
-
|
16
|
-
def start!
|
17
|
-
return if defined?(@thread)
|
18
|
-
@thread = Thread.new do
|
19
|
-
while(item = self.class.queue.pop)
|
20
|
-
begin
|
21
|
-
JobPerformer.new(klass: item[:reporter_class], args: item[:args]).perform
|
22
|
-
sleep(1)
|
23
|
-
rescue => e
|
24
|
-
ProconBypassMan.logger.error(e)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
self
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.queue
|
32
|
-
@@queue ||= Queue.new
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.push(hash)
|
36
|
-
if queue.size > MAX_QUEUE_SIZE
|
37
|
-
ProconBypassMan.logger.error('Over queue size cap!!')
|
38
|
-
return
|
39
|
-
end
|
40
|
-
|
41
|
-
queue.push(hash)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module ProconBypassMan
|
2
|
-
module Background
|
3
|
-
module JobRunnable
|
4
|
-
def perform(*)
|
5
|
-
raise NotImplementedError, nil
|
6
|
-
end
|
7
|
-
|
8
|
-
def perform_async(*args)
|
9
|
-
ProconBypassMan::Background::JobRunner.push(
|
10
|
-
args: args,
|
11
|
-
reporter_class: self,
|
12
|
-
)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|