実現したいこと
GitlabCIを初めて使っていて、コミットするごとにNuxtで作ったアプリケーションがビルドされて立ち上がるかのテストを行いたいと思っています。
調べながら .gitlab-ci.yml
を次のように記述しました。
yml
1image: node:12.16.1-alpine 2 3stages: 4 - build 5 6build: 7 stage: build 8 before_script: 9 - npm install 10 script: 11 - npm run build 12 - npm run start
自分の想定としては、 npm run start
アプリケーションの起動を確認したらスクリプトを成功として終了してくれると思っていたのですが、ずっと待受状態に入ってスクリプトが停止してくれません。
お聞きしたいこと
npm run start
が通ったのを確認してスクリプトを終了するにはどのように書けばよいのでしょうか??
試したこと
調べていたら pm2
というキーワードを得たので、
https://github.com/nuxt/nuxt.js/issues/67を参考にしてみたのですが、ローカルで pm2 start npm -- start
と打つと
[PM2] Applying action restartProcessId on app [npm](ids: [ 0 ]) [PM2] [npm](0) ✓ [PM2] Process successfully started [PM2][ERROR] Script not found: C:\Users\myName\Desktop\Nuxtプロジェクト名\start
というエラーが出てしまいました。
追記
package.json
は下記になります。
回答を頂いて、 "stop": "nxut start --force-exit"
を追記しました。
package.json
1{ 2 // 中略 3 "scripts": { 4 "dev": "nuxt", 5 "build": "nuxt build", 6 "start": "nuxt start", 7 "clean": "rm -rf .nuxt ./dist", 8 "generate": "nuxt generate", 9 "stop": "nuxt start --force-exit", 10 "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", 11 "lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore ." 12 } 13}
上記追記してからymlも追記しました。
yml
1image: node:12.16.1-alpine 2 3stages: 4 - build 5 - stop 6 7build: 8 stage: build 9 before_script: 10 - npm install 11 script: 12 - npm run build 13 - npm run start 14 - npm run stop 15 - echo "started" 16stop: 17 stage: stop 18 script: 19 - echo "stop"
gitlab上の実行画面は下記の感じで、
// npm installなど added 1391 packages from 1009 contributors and audited 30152 packages in 37.852s 33 packages are looking for funding run `npm fund` for details found 229 vulnerabilities (225 low, 4 moderate) run `npm audit fix` to fix them, or `npm audit` for details $ npm run build > hoge@1.0.0 start /builds/mates1/hoge/hoeghoge > nuxt build [log] config/.env.local $ npm run start > hoge@1.0.0 start /builds/mates1/hoge/hoeghoge > nuxt start
ここまで実行してこの状態で以降止まってしまいます。
回答1件
あなたの回答
tips
プレビュー