gpt4 book ai didi

npm - Gitlab持续集成npm后台流程

转载 作者:行者123 更新时间:2023-12-04 14:09:51 25 4
gpt4 key购买 nike

我有一个gitlab ci设置,我想在其中启动本地npm服务器以在后台进行测试。我的.gitlab-ci.yml是这样的:

stages:
- setup
- build
- test

cache:
paths:
- venv/
- node_modules/

setup_nvm:
stage: setup
script:
- "echo installing npm and phantomJS via nvm"
- "git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`"
- ". ~/.nvm/nvm.sh"
- "nvm install 5.0"
- "nvm use 5.0"
- "npm install"
- "nohup npm run dev &" # HERE I TRY TO RUN THE SERVER IN THE BACKGROUND

setup_python:
stage: setup
script:
- "echo installing python dependencies in virtual environment"
- "[ ! -d venv ] && virtualenv -p python3 venv"
- "source venv/bin/activate"
- "pip3 install -r requirements.txt"

build_multilang:
stage: build
script:
- "[ ! -d tu9onlinekurstest ] && make -f tools/makefiles/multilang"

do_tests:
stage: test
script:
- "cd src/test"
- "python -m unittest"

但是,作业暂停,并且 setup_python从未启动,并且永远处于 pending状态。我认为作业将并行执行(根据gitlabRunner文档)。您是否有使用gitlabRunner运行后台任务的经验?

最佳答案

根据Tomasz Maczukin上的a related GitLab issue:

I think the best solution would be to use some service manager (systemd, runit, upstart, sysv - whatever is present on this system).

On the server you should prepare configuration file to start the service. Then in CI job you would do e.g. systemctl start tomcat. This command is expected to exit just after calling and it's service manager (outside of Runner's scope) who starts the process.

Process started with Runner, even if you add nohup and & at the end, is marked with process group ID. When job is finished Runner is sending kill signal to whole process group. So any process started directly from CI job will be terminated at job end. Using service manager you're not starting the process in context of Runner's job. Your only notifying a manager to start a process using prepared configuration :)

关于npm - Gitlab持续集成npm后台流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38634979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com