From a8040f2288864f45e2693fb95461a220f4f988c1 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Sun, 28 Aug 2016 13:06:06 +0100 Subject: [PATCH] fix travis --- .travis.yml | 6 +--- .travis/script.sh | 13 +------- common/omeroweb_configure.sh | 9 ++++- common/virtualenv.sh | 2 +- install.sh | 5 +-- osx/nginx.sh | 7 ++++ osx/run.sh | 3 -- test/Dockerfile_ubuntu | 1 - test/test_osx.sh | 16 +++++++++ test/test_services.sh | 21 +++++++----- ubuntu/omero-web-init.d | 65 ++++++++++++++++++------------------ ubuntu/run.sh | 20 ++--------- 12 files changed, 85 insertions(+), 83 deletions(-) create mode 100755 test/test_osx.sh diff --git a/.travis.yml b/.travis.yml index 2371efe5..5328a7df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,11 +27,7 @@ matrix: - os: osx osx_image: xcode7.3 env: - - OS=osx ICE=3.6 OMEROVER=OMERO-DEV-breaking-build - - os: osx - osx_image: xcode7 - env: - - OS=osx ICE=3.6 OMEROVER=OMERO-DEV-breaking-build + - OS=osx ICE=3.6 OMEROVER=OMERO-DEV-breaking-build WEBPORT=8080 WEBPREFIX=/omero before_install: - python --version diff --git a/.travis/script.sh b/.travis/script.sh index 22dbb678..5c1a26b3 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -14,17 +14,6 @@ if [[ $TRAVIS_OS_NAME == 'linux' ]]; then else - - OMERO_USER=${OMERO_USER:-} - HOME_DIR=$(eval echo ~"$OMERO_USER") - - ./run.sh - - until [ -f ${HOME_DIR}/OMERO.py/var/django.pid ]; do - >&2 echo "OMERO.web is unavailable - sleeping" - sleep 5 - done - - curl -I http://localhost/webclient/login/ + ./test/test_osx.sh fi \ No newline at end of file diff --git a/common/omeroweb_configure.sh b/common/omeroweb_configure.sh index e27cb131..188c640c 100644 --- a/common/omeroweb_configure.sh +++ b/common/omeroweb_configure.sh @@ -4,14 +4,21 @@ set -e -u -x OMERO_USER=${OMERO_USER:-} +WEBPREFIX=${WEBPREFIX:-} WEBPORT=${WEBPORT:-80} +WEBSERVER_CONF=${WEBSERVER_CONF:-nginx} set +u source $(eval echo ~"${OMERO_USER}")/omerowebvenv/bin/activate set -u +if [[ $WEBPREFIX = *[!\ ]* ]]; then + $(eval echo ~"${OMERO_USER}")/OMERO.py/bin/omero config set omero.web.prefix "${WEBPREFIX}" + $(eval echo ~"${OMERO_USER}")/OMERO.py/bin/omero config set omero.web.static_url "${WEBPREFIX}/static/" +fi + #start-config $(eval echo ~"${OMERO_USER}")/OMERO.py/bin/omero config set omero.web.application_server wsgi-tcp -$(eval echo ~"${OMERO_USER}")/OMERO.py/bin/omero web config nginx --http "$WEBPORT" >$(eval echo ~"${OMERO_USER}")/nginx.conf.tmp +$(eval echo ~"${OMERO_USER}")/OMERO.py/bin/omero web config "${WEBSERVER_CONF}" --http "${WEBPORT}" --servername 'localhost' >$(eval echo ~"${OMERO_USER}")/nginx.conf.tmp cat $(eval echo ~"${OMERO_USER}")/nginx.conf.tmp \ No newline at end of file diff --git a/common/virtualenv.sh b/common/virtualenv.sh index c78f936b..692ed154 100644 --- a/common/virtualenv.sh +++ b/common/virtualenv.sh @@ -18,6 +18,6 @@ $(eval echo ~"${OMERO_USER}")/omerowebvenv/bin/omego download --ice $ICEVER --br zip=$(ls OMERO.py*.zip) zipname=${zip%.zip} rm -f $zip -mv $(find . -name 'OMERO.py*' -type d) OMERO.py +mv $(find . -name 'OMERO.py*' -type d) $(eval echo ~"${OMERO_USER}")/OMERO.py pip install -r $(eval echo ~"${OMERO_USER}")/OMERO.py/share/web/requirements-py27-trial.txt diff --git a/install.sh b/install.sh index 467b219f..a880c540 100755 --- a/install.sh +++ b/install.sh @@ -8,8 +8,9 @@ OS=${OS:-centos7} OMEROVER=${OMEROVER:-latest} WEBSESSION=${WEBSESSION:-} ICEVER=${ICEVER:-3.6} +WEBPREFIX=${WEBPREFIX:-} WEBPORT=${WEBPORT:-80} - +WEBSERVER_CONF=${WEBSERVER_CONF:-nginx} path=`dirname $0` @@ -33,7 +34,7 @@ fi if [[ $OMERO_USER = *[!\ ]* ]]; then su - ${OMERO_USER} -c "OMERO_USER=$OMERO_USER ICEVER=$ICEVER OMEROVER=$OMEROVER bash $path/common/virtualenv.sh" - su - ${OMERO_USER} -c "OMERO_USER=$OMERO_USER WEBPORT=$WEBPORT bash $path/common/omeroweb_configure.sh" + su - ${OMERO_USER} -c "WEBPREFIX=$WEBPREFIX WEBSERVER_CONF=$WEBSERVER_CONF OMERO_USER=$OMERO_USER WEBPORT=$WEBPORT bash $path/common/omeroweb_configure.sh" else bash $path/common/virtualenv.sh bash $path/common/omeroweb_configure.sh diff --git a/osx/nginx.sh b/osx/nginx.sh index eccd52e1..1c316895 100755 --- a/osx/nginx.sh +++ b/osx/nginx.sh @@ -2,4 +2,11 @@ set -e -u -x +OMERO_USER=${OMERO_USER:-} + brew install nginx + +mv $(eval echo ~"${OMERO_USER}")/nginx.conf.tmp /usr/local/etc/nginx/servers/omeroweb-nginx.conf + +# Restart webserver +brew services restart nginx \ No newline at end of file diff --git a/osx/run.sh b/osx/run.sh index 7bf48088..16984778 100755 --- a/osx/run.sh +++ b/osx/run.sh @@ -11,6 +11,3 @@ set -u # Start OMERO.web $(eval echo ~"${OMERO_USER}")/OMERO.py/bin/omero web start - -# Start webserver -sudo nginx -c $(eval echo ~"${OMERO_USER}")/omeroweb-nginx.conf diff --git a/test/Dockerfile_ubuntu b/test/Dockerfile_ubuntu index 618a2242..3d1728fc 100644 --- a/test/Dockerfile_ubuntu +++ b/test/Dockerfile_ubuntu @@ -29,4 +29,3 @@ RUN OMERO_USER=$OMERO_USER OS=$OS \ EXPOSE 22 80 CMD ["/bin/bash", "-e", "/tmp/omeroweb-install/omeroweb-install-test/ubuntu/run.sh"] - diff --git a/test/test_osx.sh b/test/test_osx.sh new file mode 100755 index 00000000..d5449e57 --- /dev/null +++ b/test/test_osx.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e -u -x + +WEBPORT=${WEBPORT:-80} +WEBPREFIX=${WEBPREFIX:-} + +path=`dirname $0` + +bash $path/../run.sh + +sleep 5 + +curl -I http://localhost:${WEBPORT}${WEBPREFIX}/webclient/login/ + +curl -I http://localhost:4080${WEBPREFIX}/webclient/login/ diff --git a/test/test_services.sh b/test/test_services.sh index d2118c73..cc2116eb 100755 --- a/test/test_services.sh +++ b/test/test_services.sh @@ -6,26 +6,29 @@ OS=${OS:-centos7} OMEROVER=${OMEROVER:-latest} WEBSESSION=${WEBSESSION:-} ICEVER=${ICEVER:-3.6} -WEBPORT=${WEBPORT:-80} - CNAME=omeroweb_install_test_$OS # start docker container if [[ "darwin" == "${OSTYPE//[0-9.]/}" ]]; then - WEBPORT=8888 - docker run -d --privileged -p ${WEBPORT}:80 --name $CNAME $CNAME + docker run -d --privileged -p 8888:80 --name $CNAME $CNAME else docker run -d --name $CNAME -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /run $CNAME fi +sleep 5 + # check if container is running docker inspect -f {{.State.Running}} $CNAME -sleep 5 - -curl -I http://localhost:${WEBPORT}/webclient/login/ +# Log in to OMERO.web +if [[ "darwin" == "${OSTYPE//[0-9.]/}" ]]; then + curl -I http://localhost:8888/webclient/login/ +else + DOCKER_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CNAME) + curl -I http://${DOCKER_IP}/webclient/login/ +fi # stop and cleanup -docker stop $CNAME -docker rm $CNAME +#docker stop $CNAME +#docker rm $CNAME diff --git a/ubuntu/omero-web-init.d b/ubuntu/omero-web-init.d index b3342417..0dcbfa4b 100644 --- a/ubuntu/omero-web-init.d +++ b/ubuntu/omero-web-init.d @@ -22,52 +22,53 @@ prog=omero-web # Read configuration variable file if it is present [ -r /etc/default/$prog ] && . /etc/default/$prog -# also read the omero config -[ -r /etc/default/omero ] && . /etc/default/omero + +OMERO_PY=${OMERO_PY:-/home/omero/OMERO.py} OMERO_USER=${OMERO_USER:-omero} -py_dir="/home/${OMERO_USER}/OMERO.py" -OMERO_PY=${OMERO_PY:-$py_dir} OMERO=${OMERO_PY}/bin/omero +VENVDIR=${VENVDIR:-/home/omero/omerowebvenv} -start() { - echo -n $"Starting $prog:" - su - ${OMERO_USER} -c "${OMERO} web start" &> /dev/null && echo -n ' OMERO.web' - RETVAL=$? - [ "$RETVAL" = 0 ] +start() { + echo -n $"Starting $prog:" + su - ${OMERO_USER} -c "source $VENVDIR/bin/activate; ${OMERO} web start" &> /dev/null && echo -n ' OMERO.web' + sleep 5 + ls $OMERO_PY/var/log + RETVAL=$? + [ "$RETVAL" = 0 ] echo } stop() { - echo -n $"Stopping $prog:" - su - ${OMERO_USER} -c "${OMERO} web stop" &> /dev/null && echo -n ' OMERO.web' - RETVAL=$? - [ "$RETVAL" = 0 ] + echo -n $"Stopping $prog:" + su - ${OMERO_USER} -c "source $VENVDIR/bin/activate; ${OMERO} web stop" &> /dev/null && echo -n ' OMERO.web' + RETVAL=$? + [ "$RETVAL" = 0 ] echo } status() { - echo -n $"Status $prog:" - su - ${OMERO_USER} -c "${OMERO} web status" - RETVAL=$? + echo -n $"Status $prog:" + su - ${OMERO_USER} -c "source $VENVDIR/bin/activate; ${OMERO} web status" + RETVAL=$? } case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - status) - status - ;; - *) - echo $"Usage: $0 {start|stop|restart|status}" - RETVAL=1 + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status + ;; + *) + echo $"Usage: $0 {start|stop|restart|status}" + RETVAL=1 esac exit $RETVAL diff --git a/ubuntu/run.sh b/ubuntu/run.sh index bd81799b..6dc5b0b9 100644 --- a/ubuntu/run.sh +++ b/ubuntu/run.sh @@ -2,26 +2,12 @@ set -e -u -x -while [[ $# > 1 ]] -do -key="$1" +WEBSESSION=${WEBSESSION:-} -case $key in - -w|--websession) - WEBSESSION="$2" - shift # past argument - ;; - *) - # unknown option - ;; -esac -shift # past argument or value -done - -service postgresql start if [[ $WEBSESSION = *[!\ ]* ]]; then - service redis start + service redis start fi + #service crond start # Doesn't work in Docker cron service nginx start