カテゴリー:
学習
閲覧数:308 配信日:2018-05-08 11:58
実行可能ファイルを生成&配置
$ sudo go build -o /opt/go/a1 a1.go
$ sudo go build -o /opt/go/a2 a2.go
$ sudo -s
CentOS7サービス登録
Unit定義ファイルを作成
▼/etc/systemd/system/goa1.service
# vi /etc/systemd/system/goa1.service
[Unit]
Description = go web start
[Service]
ExecStart = /opt/go/a1
Restart = always
Type = simple
[Install]
WantedBy = multi-user.target
▼/etc/systemd/system/goa2.service
# vi /etc/systemd/system/goa2.service
[Unit]
Description = go web start
[Service]
ExecStart = /opt/go/a2
Restart = always
Type = simple
[Install]
WantedBy = multi-user.target
CentOS7サービス設定
自動起動on
$ sudo systemctl enable goa1.service
$ sudo systemctl enablegoa2.service
再起動
# systemctl restart goa1.service
# systemctl restart goa2.service
デプロイ
編集する度に、下記作業が必要
$ cd /var/www/◇◇/go-demo.w4c.work/demo
$ sudo go build -o /opt/go/a1 a1.go
$ sudo go build -o /opt/go/a2 a2.go
$ systemctl restart goa1.service
$ systemctl restart goa2.service