Slide 1

Slide 1 text

メジャーな Live Reloaderの違いを ちゃんと調べて⾒た golang.tokyo #20 忘年LT⼤会!!

Slide 2

Slide 2 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved ⾃⼰紹介 • yudppp - 株式会社HRBrain CTO • 好きな⾔葉: 冪等性 • 好きなキーボード: HHKB • Corne Cherry配送待ち • Go歴 4年 • ○△□ - https://blog.yudppp.com/

Slide 3

Slide 3 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved HRBrainとは 煩雑で不透明になりがちだった⽬標・評価管理のプロセスを ⼀気通貫で効率化・⾒える化するクラウド型ソフトウェア 「⼈事評価を最もカンタン・シンプルに」

Slide 4

Slide 4 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved HRBrainの開発環境について • サーバーサイドは全てGoで実装 • docker-compose upでapp本体と関連サービスのモックを含めて全て⽴ ち上がる。 • 存在しないモックは⾃作する(yudppp/simple-sendgrid-mock- server) • Dockerのvolumeを使ってlocalのFileを更新したらコンテナ内のFileが更 新される。
 その時に⾃動でサーバーを再起動させる。 ←今回はこの話

Slide 5

Slide 5 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved Live Reloadとは • ファイルの変更を検知して、⾃動でなにかを再実⾏する。 • Hot Reload/Auto Reloadなどは多分ほぼ同義。 • GoにおけるLive Reloadとはファイルの変更を検知して、⾃動で再Buildを ⾏う

Slide 6

Slide 6 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved 特に有名なlibrary • codegangsta/gin - ★2,793 • gravityblast/fresh - ★1,856 • oxequa/realize - ★2,657 • 他にも存在はしたが、Starが1,000を超えていたのはこれだけだったので これらの⽐較をしていく。

Slide 7

Slide 7 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved codegangsta/gin • FirstCommit: Jul 21, 2013 • ちなみによく紛らわしがられるgin-gonic/ginは Jun 15, 2014

Slide 8

Slide 8 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved gravityblast/fresh • FirstCommit: Jan 12, 2014

Slide 9

Slide 9 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved oxequa/realize • FirstCommit: Jul 10, 2016

Slide 10

Slide 10 text

正直この時点で 最終更新が近くコミットの多い realize⼀択な気がしますが、 詳細機能みてきます。

Slide 11

Slide 11 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved codegangsta/gin • go run main.go の代わりに gin run main.goを実⾏するとLive Reload がすぐに使える。 --laddr value, -l value listening address for the proxy server --port value, -p value port for the proxy server (default: 3000) --appPort value, -a value port for the Go web server (default: 3001) --bin value, -b value name of generated binary file (default: "gin-bin") --path value, -t value Path to watch files from (default: ".") --build value, -d value Path to build files from (defaults to same value as --path) --excludeDir value, -x value Relative directories to exclude --immediate, -i run the server immediately after it's built --all reloads whenever any file changes, as opposed to reloading only on .go file change --godep, -g use godep when building --buildArgs value Additional go build arguments --certFile value TLS Certificate --keyFile value TLS Certificate Key --logPrefix value Setup custom log prefix --notifications enable desktop notifications --help, -h show help --version, -v print the version

Slide 12

Slide 12 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved gravityblast/fresh • fresh -c runner.conf とrootDirectory以外に動かしたい場合はconfigファ イルが必要 root: . tmp_path: ./tmp build_name: runner-build build_log: runner-build-errors.log valid_ext: .go, .tpl, .tmpl, .html no_rebuild_ext: .tpl, .tmpl, .html ignored: assets, tmp build_delay: 600 colors: 1 log_color_main: cyan log_color_build: yellow log_color_runner: green log_color_watcher: magenta log_color_app:

Slide 13

Slide 13 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved oxequa/realize • 基本的には.realize.yaml のconfigファイルを使うが--no-config のオプ ションを渡すとある程度のことをcliでできる。 settings: legacy: force: true // force polling watcher instead fsnotifiy interval: 100ms // polling interval resources: // files names outputs: outputs.log logs: logs.log errors: errors.log server: status: false // server status open: false // open browser at start host: localhost // server host port: 5001 // server port schema: - name: coin path: coin // project path env: // env variables available at startup test: test myvar: value commands: // go commands supported vet: status: true fmt: status: true args: - -s - -w test: status: true method: gb test // support different build tools generate: status: true install: status: true build: status: false method: gb build // support differents build tool args: // additional params for the command - -race run: status: true args: // arguments to pass at the project - --myarg watcher: paths: // watched paths - / ignore_paths: // ignored paths - vendor extensions: // watched extensions - go - html scripts: - type: before command: echo before global global: true output: true - type: before command: echo before change output: true - type: after command: echo after change output: true - type: after command: echo after global global: true output: true errorOutputPattern: mypattern //custom error pattern

Slide 14

Slide 14 text

みるからに設定できる項⽬が多い

Slide 15

Slide 15 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved realizeだけで実現できること • 複数のプロジェクトを⼀つのコマンドで実⾏できる • ファイル変更検知のPoling実⾏ • reload時のbefore/afterにevent hookが仕掛けられる • Web上でログやstatusの表⽰ • 環境変数の設定

Slide 16

Slide 16 text

⼈事評価を最もカンタン・シンプルに Copyright©HRBrain, Inc. All Rights Reserved ⾃分はこれからなにを使うか • Docker内で動かしたいならrealize • しっかりプロダクトの開発環境に取り込む場合はrealize • 簡単なツールでさっと⾏いたい場合はgin • 迷ったらrealize!

Slide 17

Slide 17 text

No content