stages:
- build_and_test
- deploy
web_server_build_and_test:
stage: build_and_test
script:
- mvn clean package
web_server_deploy:
stage: deploy
script:
- mvn clean package -Pprod
- service gitlab-runner-test stop
- cp target/*.war /var/gitlab-runner-test/gitlab-runner-test.war
- chmod +x /var/gitlab-runner-test/gitlab-runner-test.war
- service gitlab-runner-test start
部署阶段会产生以下输出:
$ service gitlab-runner-test stop
Stopped [13247]
$ cp target/*.war /var/gitlab-runner-test/gitlab-runner-test.war
$ chmod +x /var/gitlab-runner-test/gitlab-runner-test.war
$ service gitlab-runner-test start
Started [21177]
然而,由于runner完成阶段后服务已停止,我无法加载该应用程序:
$ service gitlab-runner-test status
Not running (process 21177 not found)
我的服务脚本将实际工作委托给组装好的war
包:
#!/usr/bin/env bash
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre/bin/java
export MODE=service
export APP_NAME=gitlab-runner-test
export PID_FOLDER=/var/run/gitlab-runner-test
/var/gitlab-runner-test/gitlab-runner-test.war $*
此外,当我手动启动服务时(
service gitlab-runner-test start
),即使用户会话已关闭,它仍然保持运行状态。我不确定问题的根源是什么——Spring Boot启动脚本、GitLab配置、我的服务脚本还是其他什么。我正在运行Ubuntu 14.04,使用GitLab CI多个runner版本0.5.0(c38415a)。升级runner到版本1.0.1(cffb5c7)并不能解决这个问题。
nohup
来启动一个进程,当父进程退出时不会杀死它。所以可以使用- nohup service gitlab-runner-test start
或者nohup /var/gitlab-runner-test/gitlab-runner-test.war $*
。 - Chloe