Ask*_*mov 8 github github-actions
我正在尝试执行以下操作:
jobs我的 Github Actions 工作流程中有以下内容:
start-process: # THIS JOB IS SUPPOSED TO START A SERVER IN BACKGROUND
name: Start
needs: start-runner # previous job starts the runner
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
steps:
- uses: actions/checkout@v2
- name: npm install
working-directory: ./monitor
run: npm install
- name: npm start
run: nohup npm start & # this starts the server in background
working-directory: ./monitor
- run: curl http://localhost:8080/start
- run: ps aux
anotherjob:
// perform another job...
Run Code Online (Sandbox Code Playgroud)
根据ps aux我的服务器进程:
root 4746 4.8 1.2 721308 48396 ? Sl 11:20 0:00 npm
root 4757 85.8 4.9 736308 196788 ? Sl 11:20 0:04 node /actions-runner/_work/<myrepo>/<myrepo>/monitor/node_modules/.bin/ts-node src/main.ts
root 4773 0.0 0.0 124052 2924 ? S 11:20 0:00 /usr/bin/bash -e /actions-runner/_work/_temp/51a508d8-9c2c-4723-9691-3252c8d53d88.sh
Run Code Online (Sandbox Code Playgroud)
但在操作日志中,我在“完成作业”下有:
Cleaning up orphan processes
Terminate orphan process: pid (4731) (npm)
Terminate orphan process: pid (4742) (node)
Run Code Online (Sandbox Code Playgroud)
所以当我再迈出一步时
statistic:
name: Output Statistics
needs:
- start-runner
- start-process
- anotherjob
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
- run: ps aux
- run: curl http://localhost:8080/statistics
Run Code Online (Sandbox Code Playgroud)
这失败了:ps aux不再有进程并且curl无法连接到该地址。
问题:如何在第一个作业中启动一个在作业结束后仍保持运行状态的进程?
事实证明,为了“保护”进程免遭清理,它可以运行为
run: RUNNER_TRACKING_ID="" && (nohup npm start&)。
这个建议是在 GitHub 上的这个线程中找到的。
| 归档时间: |
|
| 查看次数: |
5642 次 |
| 最近记录: |