[英]Travis-ci doesn't quit after running bash script over ssh to start activator
We are trying to have travis continually deploy to our own server when our build is successful. 当我们的构建成功时,我们试图使travis连续部署到我们自己的服务器上。
env:
global:
- ACTIVATOR_VERSION=1.3.7
- ACTIVATOR_ZIP_FILE=typesafe-activator-${ACTIVATOR_VERSION}-minimal.zip
- ACTIVATOR_ZIP_URL=http://downloads.typesafe.com/typesafe-activator/${ACTIVATOR_VERSION}/${ACTIVATOR_ZIP_FILE}
- ACTIVATOR_BIN=${TRAVIS_BUILD_DIR}/activator-${ACTIVATOR_VERSION}-minimal/activator
- "DEPLOY_USERNAME=#######"
- "DEPLOY_PASSWORD=########"
- "DEPLOY_HOST=########"
language: java
jdk:
- oraclejdk8
addons:
ssh_known_hosts:
- ########
apt:
packages:
- sshpass
install:
- wget $ACTIVATOR_ZIP_URL
- unzip -q $ACTIVATOR_ZIP_FILE
script:
- $ACTIVATOR_BIN test
after_success:
- sshpass -p $DEPLOY_PASSWORD ssh $DEPLOY_USERNAME@$DEPLOY_HOST -o stricthostkeychecking=no 'bash deploy.sh'
After our travis finishes without errors it runs an ssh script on our server to pull from our git, stop our running activator and start a new one. travis正确完成后,它将在服务器上运行ssh脚本以从git中提取信息,停止运行中的激活器并启动新的激活器。 The script: 剧本:
#!/bin/bash
#Get the path of the local repository directory
set -o verbose
DIR="/home/ftpuser/eaglescience/"
TARGET="origin/develop"
SLEEP=1m
#echo "Go into directory " ${DIR}
cd ${DIR}
PID="`cat target/universal/stage/RUNNING_PID`"
#echo "Get the code from " ${TARGET}
git fetch --all
#echo "force checkout"
git checkout --force "${TARGET}"
#echo "Compiling activator"
activator clean stage
#echo "Running activator"
kill -15 ${PID}
target/universal/stage/bin/eaglescience -Dapplication.secret=############### &
#echo "Running..."
sleep ${SLEEP}
exit 0
The problem here is that Travis-ci does not exit the bash script after it runs (even with the exit 0). 这里的问题是Travis-ci在运行后不会退出bash脚本(即使退出为0)。 This means that Travis-CI will keep waiting for a response until it times out and erros our build 这意味着Travis-CI将一直等待响应,直到响应超时并破坏我们的构建
The response we got after a while is the following: 一段时间后,我们得到的响应如下:
[success] Total time: 33 s, completed Mar 9, 2016 11:19:20 AM
#echo "Running activator"
kill -15 ${PID}
target/universal/stage/bin/eaglescience -Dapplication.secret=########### &
#echo "Running..."
sleep ${SLEEP}
[warn] - application - system properties: application.secret is deprecated, use play.crypto.secret instead
[info] - play.api.Play - Application started (Prod)
[info] - play.core.server.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
exit 0
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated
We have tried a lot of different things, we have tried to run the ssh bash command silent. 我们尝试了很多不同的方法,我们尝试了静默运行ssh bash命令。 But then travis-ci terminates the connection almost instantly and the command wil not run. 但是随后travis-ci几乎立即终止了连接,该命令将无法运行。 We also tried to add && exit 0
but then the server still keeps waiting on response. 我们还尝试添加&& exit 0
但服务器仍继续等待响应。
尝试使用nohup
输出到/dev/null 2>&1 &
的shell文件,例如: nohup filename.sh > /dev/null 2>&1 &
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.