From 483d87ed8064573f60194f7936701d21f8728e61 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 16 Nov 2011 15:21:07 +0100 Subject: Fixed PORT to NGINX_PORT --- aa-server.yaml | 30 +++++++++++++++--------------- config.sh | 4 ++-- nginx.conf | 12 ++++++------ nginx.sh | 8 ++++---- opentox-ruby.sh | 4 ++-- production.yaml | 14 +++++++------- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/aa-server.yaml b/aa-server.yaml index 5ca2b72..aa08799 100644 --- a/aa-server.yaml +++ b/aa-server.yaml @@ -15,25 +15,25 @@ # Exceptions: :free_uris: #request-method for uri not controlled by A&A ? - :GET - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/algorithm/ - - "http://SERVERNAMEPORT/model" - - "http://SERVERNAMEPORT/dataset" - - "http://SERVERNAMEPORT/validation" - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/validation\/resources/ - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/validation\/[a-z,A-Z,\/,_\-]*$/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/algorithm/ + - "http://SERVERNAMENGINX_PORT/model" + - "http://SERVERNAMENGINX_PORT/dataset" + - "http://SERVERNAMENGINX_PORT/validation" + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/validation\/resources/ + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/validation\/[a-z,A-Z,\/,_\-]*$/ ? - :GET - :POST - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/toxcreate\/[a-z,A-Z,\/,_\-]*$/ - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/task/ - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/compound/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/toxcreate\/[a-z,A-Z,\/,_\-]*$/ + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/task/ + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/compound/ - !ruby/regexp /sign_(in|out)$/ ? - :PUT - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/task/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/task/ :authorize_exceptions: #request-method for uri only authenticated, no authorization ? - :POST - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/algorithm/ - - "http://SERVERNAMEPORT/dataset" - - "http://SERVERNAMEPORT/model" - - "http://SERVERNAMEPORT/validation" - - !ruby/regexp /http\:\/\/ESCAPEDSERVERPORT\/validation\/[a-z,A-Z,\/,_\-]*$/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/algorithm/ + - "http://SERVERNAMENGINX_PORT/dataset" + - "http://SERVERNAMENGINX_PORT/model" + - "http://SERVERNAMENGINX_PORT/validation" + - !ruby/regexp /http\:\/\/ESCAPEDSERVERNGINX_PORT\/validation\/[a-z,A-Z,\/,_\-]*$/ diff --git a/config.sh b/config.sh index 9ebd47d..a50b05b 100755 --- a/config.sh +++ b/config.sh @@ -22,8 +22,8 @@ REDIS_NUM_VER="2.2.2" # 4) Server settings. NGINX_SERVERNAME="toxcreate3.in-silico.ch" WWW_DEST="$OT_PREFIX/www" -PORT=":8081" # set to empty string ("") for port 80 otherwise set to port *using colon* e.g. ":8080" -OHM_PORT="6379" # set to port (no colon) +NGINX_PORT=":8081" # set to empty string ("") for port 80 otherwise set to port *using colon* e.g. ":8080" +OHM_PORT="6380" # set to port (no colon) # Done. diff --git a/nginx.conf b/nginx.conf index 4372940..6a8186a 100644 --- a/nginx.conf +++ b/nginx.conf @@ -8,14 +8,14 @@ http { server_names_hash_bucket_size 256; - passenger_root RUBY_DEST/lib/ruby/gems/1.8/gems/PASSENGER; - passenger_ruby RUBY_DEST/bin/ruby; - passenger_default_user USER; + passenger_root /home/am/opentox-ruby/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/passenger-3.0.9; + passenger_ruby /home/am/opentox-ruby/ruby-enterprise-1.8.7-2011.03/bin/ruby; + passenger_default_user am; passenger_log_level 2; passenger_spawn_method conservative; #passenger_use_global_queue on; - include NGINX_DEST/conf/mime.types; + include /home/am/opentox-ruby/nginx/conf/mime.types; default_type application/octet-stream; sendfile on; @@ -25,9 +25,9 @@ http { server { listen PORT; client_max_body_size 5000m; - server_name SERVERNAME; + server_name z21mn; location / { - root WWW_DEST; + root /home/am/opentox-ruby/www; passenger_enabled on; } passenger_base_uri /compound; diff --git a/nginx.sh b/nginx.sh index 3a872bc..32efc96 100755 --- a/nginx.sh +++ b/nginx.sh @@ -53,11 +53,11 @@ servername=`hostname` $GIT checkout nginx.conf>>$LOG 2>&1 cmd="sed -i -e \"s,PASSENGER,$passenger,;s,SERVERNAME,$servername,;s,RUBY_DEST,$RUBY_DEST,;s,NGINX_DEST,$NGINX_DEST,;s,WWW_DEST,$WWW_DEST,\" ./nginx.conf" && run_cmd "$cmd" "Config" cmd="sed -i -e \"s,USER,`whoami`,\" ./nginx.conf" && run_cmd "$cmd" "User" -PORT=`echo "$PORT" | sed 's/^.//g'` -if [ -z "$PORT" ]; then - PORT=80 +NGINX_PORT=`echo "$NGINX_PORT" | sed 's/^.//g'` +if [ -z "$NGINX_PORT" ]; then + NGINX_PORT=80 fi -cmd="sed -i -e \"s,PORT,$PORT,\" ./nginx.conf" && run_cmd "$cmd" "Port" +cmd="sed -i -e \"s,NGINX_PORT,$NGINX_PORT,\" ./nginx.conf" && run_cmd "$cmd" "NGINX_PORT" cmd="cp ./nginx.conf \"$NGINX_DEST/conf\"" && run_cmd "$cmd" "Copy" if [ ! -f $NGINX_CONF ]; then diff --git a/opentox-ruby.sh b/opentox-ruby.sh index f6fa077..ec7f5c2 100755 --- a/opentox-ruby.sh +++ b/opentox-ruby.sh @@ -71,8 +71,8 @@ mkdir -p "$HOME/.opentox/tmp" >>$LOG 2>&1 $GIT checkout production.yaml >>$LOG 2>&1 $GIT checkout aa-$OT_INSTALL.yaml >>$LOG 2>&1 -cmd="sed -e \"s,SERVERNAME,$servername,;s,ESCAPEDSERVER,$escapedserver,;s,LOGGER,$logger,;s,AA,$aa,;s,WWW_DEST,$WWW_DEST,;s,PORT,$PORT,;s,OHM_PORT,$OHM_PORT,\" production.yaml > $HOME/.opentox/config/production.yaml" && run_cmd "$cmd" "Config 1" -cmd="sed -e \"s,SERVERNAME,$servername,;s,ESCAPEDSERVER,$escapedserver,;s,LOGGER,$logger,;s,AA,$aa,;s,WWW_DEST,$WWW_DEST,;s,PORT,$PORT,;s,OHM_PORT,$OHM_PORT,\" aa-$OT_INSTALL.yaml >> $HOME/.opentox/config/production.yaml" && run_cmd "$cmd" "Config 2" +cmd="sed -e \"s,SERVERNAME,$servername,;s,ESCAPEDSERVER,$escapedserver,;s,LOGGER,$logger,;s,AA,$aa,;s,WWW_DEST,$WWW_DEST,;s,NGINX_PORT,$NGINX_PORT,;s,OHM_PORT,$OHM_PORT,\" production.yaml > $HOME/.opentox/config/production.yaml" && run_cmd "$cmd" "Config 1" +cmd="sed -e \"s,SERVERNAME,$servername,;s,ESCAPEDSERVER,$escapedserver,;s,LOGGER,$logger,;s,AA,$aa,;s,WWW_DEST,$WWW_DEST,;s,NGINX_PORT,$NGINX_PORT,;s,OHM_PORT,$OHM_PORT,\" aa-$OT_INSTALL.yaml >> $HOME/.opentox/config/production.yaml" && run_cmd "$cmd" "Config 2" if [ "$OT_BRANCH" = "development" ] || expr match "$OT_BRANCH" "release"; then mkdir -p $WWW_DEST/opentox >>$LOG 2>&1 diff --git a/production.yaml b/production.yaml index 709b133..e0f39d4 100644 --- a/production.yaml +++ b/production.yaml @@ -2,13 +2,13 @@ :services: # make sure to enter a full uri (including training slash) - opentox-compound: "http://SERVERNAMEPORT/compound/" - opentox-dataset: "http://SERVERNAMEPORT/dataset/" - opentox-algorithm: "http://SERVERNAMEPORT/algorithm/" - opentox-model: "http://SERVERNAMEPORT/model/" - opentox-task: "http://SERVERNAMEPORT/task/" - opentox-toxcreate: "http://SERVERNAMEPORT/toxcreate/" - opentox-validation: "http://SERVERNAMEPORT/validation/" + opentox-compound: "http://SERVERNAMENGINX_PORT/compound/" + opentox-dataset: "http://SERVERNAMENGINX_PORT/dataset/" + opentox-algorithm: "http://SERVERNAMENGINX_PORT/algorithm/" + opentox-model: "http://SERVERNAMENGINX_PORT/model/" + opentox-task: "http://SERVERNAMENGINX_PORT/task/" + opentox-toxcreate: "http://SERVERNAMENGINX_PORT/toxcreate/" + opentox-validation: "http://SERVERNAMENGINX_PORT/validation/" opentox-ontology: "http://apps.ideaconsult.net:8080/ontology" :json_hosts: -- cgit v1.2.3 From 21240d7fad96d6e2205f497f44de16a4658e4516 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 16 Nov 2011 15:23:04 +0100 Subject: Fixed PORT to NGINX_PORT --- aa-local.yaml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/aa-local.yaml b/aa-local.yaml index 5ca2b72..aa08799 100644 --- a/aa-local.yaml +++ b/aa-local.yaml @@ -15,25 +15,25 @@ # Exceptions: :free_uris: #request-method for uri not controlled by A&A ? - :GET - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/algorithm/ - - "http://SERVERNAMEPORT/model" - - "http://SERVERNAMEPORT/dataset" - - "http://SERVERNAMEPORT/validation" - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/validation\/resources/ - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/validation\/[a-z,A-Z,\/,_\-]*$/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/algorithm/ + - "http://SERVERNAMENGINX_PORT/model" + - "http://SERVERNAMENGINX_PORT/dataset" + - "http://SERVERNAMENGINX_PORT/validation" + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/validation\/resources/ + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/validation\/[a-z,A-Z,\/,_\-]*$/ ? - :GET - :POST - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/toxcreate\/[a-z,A-Z,\/,_\-]*$/ - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/task/ - - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/compound/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/toxcreate\/[a-z,A-Z,\/,_\-]*$/ + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/task/ + - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/compound/ - !ruby/regexp /sign_(in|out)$/ ? - :PUT - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/task/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/task/ :authorize_exceptions: #request-method for uri only authenticated, no authorization ? - :POST - : - !ruby/regexp /http:\/\/ESCAPEDSERVERPORT\/algorithm/ - - "http://SERVERNAMEPORT/dataset" - - "http://SERVERNAMEPORT/model" - - "http://SERVERNAMEPORT/validation" - - !ruby/regexp /http\:\/\/ESCAPEDSERVERPORT\/validation\/[a-z,A-Z,\/,_\-]*$/ + : - !ruby/regexp /http:\/\/ESCAPEDSERVERNGINX_PORT\/algorithm/ + - "http://SERVERNAMENGINX_PORT/dataset" + - "http://SERVERNAMENGINX_PORT/model" + - "http://SERVERNAMENGINX_PORT/validation" + - !ruby/regexp /http\:\/\/ESCAPEDSERVERNGINX_PORT\/validation\/[a-z,A-Z,\/,_\-]*$/ -- cgit v1.2.3 From 80115dd66a89823fac1dac4690a6c8e87b530a2b Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 16 Nov 2011 15:25:00 +0100 Subject: Fixed PORT to NGINX_PORT --- nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index 6a8186a..0ff4dec 100644 --- a/nginx.conf +++ b/nginx.conf @@ -23,7 +23,7 @@ http { # webservices server { - listen PORT; + listen NGINX_PORT; client_max_body_size 5000m; server_name z21mn; location / { -- cgit v1.2.3 From 18880d3774f9f93cba7341f93498ca33fdabc169 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 16 Nov 2011 16:03:14 +0100 Subject: Fixed PORT to NGINX_PORT --- nginx.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nginx.conf b/nginx.conf index 0ff4dec..9f87adf 100644 --- a/nginx.conf +++ b/nginx.conf @@ -8,14 +8,14 @@ http { server_names_hash_bucket_size 256; - passenger_root /home/am/opentox-ruby/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/passenger-3.0.9; - passenger_ruby /home/am/opentox-ruby/ruby-enterprise-1.8.7-2011.03/bin/ruby; - passenger_default_user am; + passenger_root RUBY_DEST/lib/ruby/gems/1.8/gems/PASSENGER; + passenger_ruby RUBY_DEST/bin/ruby; + passenger_default_user USER; passenger_log_level 2; passenger_spawn_method conservative; #passenger_use_global_queue on; - include /home/am/opentox-ruby/nginx/conf/mime.types; + include NGINX_DEST/conf/mime.types; default_type application/octet-stream; sendfile on; @@ -25,9 +25,9 @@ http { server { listen NGINX_PORT; client_max_body_size 5000m; - server_name z21mn; + server_name SERVERNAME; location / { - root /home/am/opentox-ruby/www; + root WWW_DEST; passenger_enabled on; } passenger_base_uri /compound; -- cgit v1.2.3 From ecb20ea48a05feb74f86408ccd27ecc274d08080 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 16 Nov 2011 17:20:46 +0100 Subject: Separate file for ot-tools --- README | 84 ++++---------------------------------------------------- ot-tools-user.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 79 deletions(-) create mode 100644 ot-tools-user.sh diff --git a/README b/README index db3b9c0..00ed726 100644 --- a/README +++ b/README @@ -13,7 +13,11 @@ Here are some of my goals when writing the installer: - Encapsulated (everything is installed in a sub-directory in $HOME) - Logged (all non-elemtary actions are logged) -Even if we officially support only *one* distro (currently Debian 6.0.1), I tested the installer successfully on various Ubuntus. In the README at the top are the requirements of the installer. By default, everything is installed to $HOME/opentox-ruby (=OT_PREFIX). The configs go to OT_PREFIX/.sh__ot.sh for each package. + +Configure your system in config.sh. +NOTE for variable NGINX_PORT: leave this empty or set to ":80" to use port 80. If you do this, use the ot-scripts in "ot-tools-root.sh". Otherwise, if NGINX_PORT >1024, use ot-scripts in "ot-tools-user.sh". + +Even if we officially support only *one* distro (currently Debian 6.0.1), I tested the installer successfully on various Ubuntus. In this README at the top are the requirements of the installer. By default, everything is installed to $HOME/opentox-ruby (=OT_PREFIX). The configs go to OT_PREFIX/.sh__ot.sh for each package. After running the installer, configure the system by editing the startup file of your favorite shell (in my case, BASH with the file ~ /. bashrc) to include ~/.opentox-ui.sh (in my case with 'source ...'). This file is the only one that the installer creates outside OT_PREFIX. Thus, the system is fully configured: If you now open a new shell, all environment variables will be adjusted. @@ -24,82 +28,4 @@ nohup $HOME/opentox-ruby/nginx/sbin/nginx -c $HOME/opentox-ruby/nginx/conf/nginx To uninstall the system simply delete the link from the startup file: Done. To save disc space delete directory OT_PREFIX. Anyone can run multiple Opentox versions on the same machine: Just install again, but to a different OT_PREFIX. The switch works manually: Include the sh__ot.sh files from the desired OT_PREFIX in $HOME/opentox-ui.sh (only one installation may be activated at any time). -Some useful scripts to put in your ~/.bashrc in case you are using bash (assuming OT_PREFIX is '~/opentox-ruby'): - -# Load server config -otconfig() { - source $HOME/.opentox-ui.sh -} - -# Update the version -otupdate() { - START_DIR=`pwd` - otconfig - cd $HOME/opentox-ruby/www/opentox - for d in `find -not -name "." -type d -maxdepth 1 2>/dev/null`; do echo ; echo $d ; cd $d ; MYBRANCH=`git branch | grep "*" | sed 's/.*\ //g'`; git pull origin $MYBRANCH ; cd - ; done - cd $HOME/opentox-ruby/www/opentox/algorithm/libfminer - mv libbbrc/Makefile libbbrc/Makefile~ - mv liblast/Makefile liblast/Makefile~ - if ! git pull; then - echo "Error! Pull for Fminer failed." - return 1 - fi - mv libbbrc/Makefile~ libbbrc/Makefile - mv liblast/Makefile~ liblast/Makefile - make -C libbbrc/ clean - make -C libbbrc/ ruby - make -C liblast/ clean - make -C liblast/ ruby - cd - - cd $HOME/opentox-ruby/www/opentox/algorithm/last-utils - if ! git pull; then - echo "Error! Pull for Last-Utils failed." - return 1 - fi - cd - - cd opentox-ruby - LINK_DIR=`gem which opentox-ruby | sed 's/\/opentox-ruby.rb//'` - if [ -h $LINK_DIR ]; then - rm -f $LINK_DIR - fi - rake install - if ! [ -h $LINK_DIR ]; then - echo "Warning! Your lib $LINK_DIR is no symlink. Linking back for you..." - rm -rf "$LINK_DIR~" - mv "$LINK_DIR" "$LINK_DIR~" - ln -sf $HOME/opentox-ruby/www/opentox/opentox-ruby/lib `echo ${LINK_DIR::${#LINK_DIR}-3}` - fi - echo "Please execute 'otstart' to restart." - cd "$START_DIR" -} - -# Start the server -otstart() { - otkill - bash -c "source $HOME/.opentox-ui.sh; nohup redis-server $HOME/opentox-ruby/redis-2.2.2/redis.conf >/dev/null 2>&1 &" - bash -c "source $HOME/.opentox-ui.sh; nohup nginx -c $HOME/opentox-ruby/nginx/conf/nginx.conf >/dev/null 2>&1 &" - sleep 2 - if ! pgrep -u $USER nginx>/dev/null 2>&1; then echo "Failed to start nginx."; fi - if ! pgrep -u $USER redis-server>/dev/null 2>&1; then echo "Failed to start redis."; fi -} - -# Display log -alias otless='less $HOME/.opentox/log/production.log' - -# Tail log -alias ottail='tail -f $HOME/.opentox/log/production.log' - -# Reload the server -otreload() { - bash -c "source $HOME/.opentox-ui.sh; nginx -s reload" -} - -# Kill the server -otkill() { - killall nginx >/dev/null 2>&1 - bash -c "source $HOME/.opentox-ui.sh; redis-cli shutdown >/dev/null 2>&1" - while ps x | grep PassengerWatchdog | grep -v grep >/dev/null 2>&1; do sleep 1; done - while ps x | grep Rack | grep -v grep >/dev/null 2>&1; do sleep 1; done - for p in `pgrep -u $USER R 2>/dev/null`; do kill -9 $p; done -} diff --git a/ot-tools-user.sh b/ot-tools-user.sh new file mode 100644 index 0000000..64f26d3 --- /dev/null +++ b/ot-tools-user.sh @@ -0,0 +1,80 @@ +# Some useful scripts to put in your ~/.bashrc in case you are using bash (assuming OT_PREFIX is '~/opentox-ruby'): +# USE ONLY IF YOUR NGINX PORT IS >1024 (NOT PRIVILEGED) + +# Load server config +otconfig() { + source $HOME/.opentox-ui.sh +} + +# Update the version +otupdate() { + START_DIR=`pwd` + otconfig + cd $HOME/opentox-ruby/www/opentox + for d in `find -not -name "." -type d -maxdepth 1 2>/dev/null`; do echo ; echo $d ; cd $d ; MYBRANCH=`git branch | grep "*" | sed 's/.*\ //g'`; git pull origin $MYBRANCH ; cd - ; done + cd $HOME/opentox-ruby/www/opentox/algorithm/libfminer + mv libbbrc/Makefile libbbrc/Makefile~ + mv liblast/Makefile liblast/Makefile~ + if ! git pull; then + echo "Error! Pull for Fminer failed." + return 1 + fi + mv libbbrc/Makefile~ libbbrc/Makefile + mv liblast/Makefile~ liblast/Makefile + make -C libbbrc/ clean + make -C libbbrc/ ruby + make -C liblast/ clean + make -C liblast/ ruby + cd - + cd $HOME/opentox-ruby/www/opentox/algorithm/last-utils + if ! git pull; then + echo "Error! Pull for Last-Utils failed." + return 1 + fi + cd - + cd opentox-ruby + LINK_DIR=`gem which opentox-ruby | sed 's/\/opentox-ruby.rb//'` + if [ -h $LINK_DIR ]; then + rm -f $LINK_DIR + fi + rake install + if ! [ -h $LINK_DIR ]; then + echo "Warning! Your lib $LINK_DIR is no symlink. Linking back for you..." + rm -rf "$LINK_DIR~" + mv "$LINK_DIR" "$LINK_DIR~" + ln -sf $HOME/opentox-ruby/www/opentox/opentox-ruby/lib `echo ${LINK_DIR::${#LINK_DIR}-3}` + fi + echo "Please execute 'otstart' to restart." + cd "$START_DIR" +} + +# Start the server +otstart() { + otkill + bash -c "source $HOME/.opentox-ui.sh; nohup redis-server $HOME/opentox-ruby/redis-2.2.2/redis.conf >/dev/null 2>&1 &" + bash -c "source $HOME/.opentox-ui.sh; nohup nginx -c $HOME/opentox-ruby/nginx/conf/nginx.conf >/dev/null 2>&1 &" + sleep 2 + if ! pgrep -u $USER nginx>/dev/null 2>&1; then echo "Failed to start nginx."; fi + if ! pgrep -u $USER redis-server>/dev/null 2>&1; then echo "Failed to start redis."; fi +} + +# Display log +alias otless='less $HOME/.opentox/log/production.log' + +# Tail log +alias ottail='tail -f $HOME/.opentox/log/production.log' + +# Reload the server +otreload() { + bash -c "source $HOME/.opentox-ui.sh; nginx -s reload" +} + +# Kill the server +otkill() { + killall nginx >/dev/null 2>&1 + bash -c "source $HOME/.opentox-ui.sh; redis-cli shutdown >/dev/null 2>&1" + while ps x | grep PassengerWatchdog | grep -v grep >/dev/null 2>&1; do sleep 1; done + while ps x | grep Rack | grep -v grep >/dev/null 2>&1; do sleep 1; done + for p in `pgrep -u $USER R 2>/dev/null`; do kill -9 $p; done +} + -- cgit v1.2.3 From 47cdf2243d076ade575894fdefe14f99107e2160 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 16 Nov 2011 17:30:08 +0100 Subject: Using separate files for ot-tools --- README | 3 +-- ot-tools-root.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 ot-tools-root.sh diff --git a/README b/README index 00ed726..7828109 100644 --- a/README +++ b/README @@ -14,8 +14,7 @@ Here are some of my goals when writing the installer: - Logged (all non-elemtary actions are logged) -Configure your system in config.sh. -NOTE for variable NGINX_PORT: leave this empty or set to ":80" to use port 80. If you do this, use the ot-scripts in "ot-tools-root.sh". Otherwise, if NGINX_PORT >1024, use ot-scripts in "ot-tools-user.sh". +Configure your system in config.sh. NOTE for variable NGINX_PORT: leave this empty or set to ":80" to use port 80. If you do this, use the ot-scripts in "ot-tools-root.sh". Otherwise, if NGINX_PORT >1024, use ot-scripts in "ot-tools-user.sh". Even if we officially support only *one* distro (currently Debian 6.0.1), I tested the installer successfully on various Ubuntus. In this README at the top are the requirements of the installer. By default, everything is installed to $HOME/opentox-ruby (=OT_PREFIX). The configs go to OT_PREFIX/.sh__ot.sh for each package. diff --git a/ot-tools-root.sh b/ot-tools-root.sh new file mode 100644 index 0000000..eec6780 --- /dev/null +++ b/ot-tools-root.sh @@ -0,0 +1,79 @@ +# Some useful scripts to put in your ~/.bashrc in case you are using bash (assuming OT_PREFIX is '~/opentox-ruby'): +# USE ONLY IF YOUR NGINX PORT IS less or equal to 1024 (PRIVILEGED) + +# Load server config +otconfig() { + source $HOME/.opentox-ui.sh +} + +# Update the version +otupdate() { + START_DIR=`pwd` + otconfig + cd $HOME/opentox-ruby/www/opentox + for d in `find -not -name "." -type d -maxdepth 1 2>/dev/null`; do echo ; echo $d ; cd $d ; MYBRANCH=`git branch | grep "*" | sed 's/.*\ //g'`; git pull origin $MYBRANCH ; cd - ; done + cd $HOME/opentox-ruby/www/opentox/algorithm/libfminer + mv libbbrc/Makefile libbbrc/Makefile~ + mv liblast/Makefile liblast/Makefile~ + if ! git pull; then + echo "Error! Pull for Fminer failed." + return 1 + fi + mv libbbrc/Makefile~ libbbrc/Makefile + mv liblast/Makefile~ liblast/Makefile + make -C libbbrc/ clean + make -C libbbrc/ ruby + make -C liblast/ clean + make -C liblast/ ruby + cd - + cd $HOME/opentox-ruby/www/opentox/algorithm/last-utils + if ! git pull; then + echo "Error! Pull for Last-Utils failed." + return 1 + fi + cd - + cd opentox-ruby + LINK_DIR=`gem which opentox-ruby | sed 's/\/opentox-ruby.rb//'` + if [ -h $LINK_DIR ]; then + rm -f $LINK_DIR + fi + rake install + if ! [ -h $LINK_DIR ]; then + echo "Warning! Your lib $LINK_DIR is no symlink. Linking back for you..." + rm -rf "$LINK_DIR~" + mv "$LINK_DIR" "$LINK_DIR~" + ln -sf $HOME/opentox-ruby/www/opentox/opentox-ruby/lib `echo ${LINK_DIR::${#LINK_DIR}-3}` + fi + echo "Please execute 'otstart' to restart." + cd "$START_DIR" +} + +# Start the server +otstart() { + otkill + sudo bash -c "source $HOME/.opentox-ui.sh; nohup redis-server $HOME/opentox-ruby/redis-2.2.2/redis.conf >/dev/null 2>&1 &" + sudo bash -c "source $HOME/.opentox-ui.sh; nohup nginx -c $HOME/opentox-ruby/nginx/conf/nginx.conf >/dev/null 2>&1 &" + sleep 2 + if ! pgrep -u root nginx>/dev/null 2>&1; then echo "Failed to start nginx."; fi + if ! pgrep -u root redis-server>/dev/null 2>&1; then echo "Failed to start redis."; fi +} + +# Display log +alias otless='less $HOME/.opentox/log/production.log' + +# Tail log +alias ottail='tail -f $HOME/.opentox/log/production.log' + +# Reload the server +otreload() { + sudo bash -c "source $HOME/.opentox-ui.sh; nginx -s reload" +} + +# Kill the server +otkill() { + sudo killall -u root nginx >/dev/null 2>&1 + sudo bash -c "source $HOME/.opentox-ui.sh; redis-cli shutdown >/dev/null 2>&1" + while sudo ps x | grep PassengerWatchdog | grep -v grep >/dev/null 2>&1; do sleep 1; done + while sudo ps x | grep Rack | grep -v grep >/dev/null 2>&1; do sleep 1; done + for p in `pgrep -u root R 2>/dev/null`; do sudo kill -9 $p; done +} -- cgit v1.2.3