2016-03-09 104 views
1

我們試圖在構建成功時讓travis不斷部署到我們自己的服務器。通過ssh運行bash腳本啓動激活器後,Travis-ci不會退出

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 [email protected]$DEPLOY_HOST -o stricthostkeychecking=no 'bash deploy.sh' 

之後,我們的特拉維斯完成且沒有錯誤,它運行在我們的服務器上的SSH腳本從我們的混帳拉,停止我們運行的激活,並開始一個新的。 腳本:

#!/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 

這裏的問題是,它運行後,特拉維斯慈不退出bash腳本(甚至退出0)。這意味着,特拉維斯 - CI將繼續等待響應,直到超時和錯誤回報我們的構建

我們一段時間後得到的迴應是:

[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 

我們已經嘗試了很多不同的事情,我們試圖運行ssh bash命令silent。但是,然後travis-ci幾乎立即終止連接,命令不會運行。我們還嘗試添加&& exit 0,但是服務器仍在等待響應。

回答

0

嘗試使用nohup與輸出的外殼文件/dev/null 2>&1 &例如:nohup filename.sh > /dev/null 2>&1 &

+0

喂Jespert,謝謝你的回答,很遺憾我無法檢查你的答案,因爲這是一個項目,我做了,而一去,我已經解決它在另一個方面。但謝謝你的答案! – Bjorn

+0

你是如何解決它的? – Jespert

+0

說實話我不知道,這是一段時間後,當我完成這個項目對不起。 – Bjorn