DEV Community

KOGA Mitsuhiro
KOGA Mitsuhiro

Posted on • Originally published at qiita.com

Unity Accelerator + Prometheus + GrafanaをDockerでサービス化する

はじめに

Unity2019.3からAsset Pipeline v2が追加されてUnity Acceleratorを組み合わせるとインポートしたアセットをキャッシュおよび共有することができます。

それまでのUnityにもAsset Pipeline v1とキャッシュサーバーでキャッシュできていましたが、Unity Acceleratorには以下の違いがあります。

  • キャッシュサーバーと同居できる
  • Collaborateのキャッシュに対応
  • 不要なキャッシュを定期的にクリーンアップ
  • 転送されたバイト数や接続されたエディターなどの情報をPrometheusから利用できるメトリクスで公開

フォーラムの以下のスレッドによるとDockerHubでイメージが公開されています。

Unity AcceleratorはPrometheusとダッシュボードのGrafanaを組み合わせるとメトリクスを可視化できるのでdocker-composeでサービス化しました。

Dockerでサービス化

https://github.com/shiena/docker-unity-accelerator

設定ファイル

COLLAB_REGISTRATION_TOKEN=ft0bJvbRD
DISABLE_USAGE_STATS=yes
Enter fullscreen mode Exit fullscreen mode
  • Unity Collaborateと連携する場合はCOLLAB_REGISTRATION_TOKENにトークンを設定します。
  • 統計情報の送信を抑制する場合はDISABLE_USAGE_STATSに任意の値を設定します。

サービスを実行

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

サービスを起動するとそれぞれ以下からアクセスできます。

GrafanaではUnity - Manual: Unity Acceleratorの一覧にあるメトリクスを扱えます。

Local Administraotr Dashboard

v1.0.272+gb7c26b9からLocal Administrator Dashboardが追加されて http://localhost:10080 からアクセスできるようになりました。

ConfigurationとLogsは以下のコマンドでパスワード設定が必要です。

docker-compose exec accelerator /agent/unity-accelerator tool adminpw mysupersecretpassword ​
Enter fullscreen mode Exit fullscreen mode

image.png

公式イメージ公開前にDocker化で工夫したこと

  • Unity AcceleratorをダウンロードするURLからバージョンが分からないのでバージョンを確認する方法を用意しています。
  • v1.0.196+ge1f9988で修正されました。キャッシュサーバー追加でインストーラーを非対話モードで実行するとnpmのパスが展開されないバグがあるので対話モードprintfで強引にインストールしています。(バグ報告済み)
  • v1.0.242+gf11031dで修正されました。v1.0.196+ge1f9988で初回起動時などpidファイルがなかったり空の時に起動できないバグがあるのでパッチを当てています。
  • 公式イメージが公開されたので独自Dockerfileから切り替えました。

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay