Browse Source

Updated start/stream and fixed nginx

msmith-techempower 10 years ago
parent
commit
deb72f39e9

+ 0 - 32
frameworks/Dart/dart-redstone/setup.py

@@ -1,32 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-
-def start(args, logfile, errfile):
-  setup_util.replace_text('dart-redstone/postgresql.yaml', 'host: .*', 'host: ' + args.database_host)
-  setup_util.replace_text('dart-redstone/mongodb.yaml', 'host: .*', 'host: ' + args.database_host)
-  try:
-    #
-    # install dart dependencies
-    #
-    subprocess.check_call('pub upgrade', shell=True, cwd='dart-redstone', stderr=errfile, stdout=logfile)
-    #
-    # start dart servers
-    #
-    subprocess.Popen('dart server.dart -a 0.0.0.0 -p 8080 -d ' + str(args.max_concurrency) + ' -i ' + str(args.max_threads), shell=True, cwd='dart-redstone', stderr=errfile, stdout=logfile)
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-def stop(logfile, errfile):
-  #
-  # stop dart servers
-  #
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'dart' in line and 'run-tests' not in line and 'run-ci' not in line:
-      pid = int(line.split(None, 2)[1])
-      os.kill(pid, 15)
-  return 0

+ 7 - 0
frameworks/Dart/dart-start/bash_profile.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+export DART_HOME=$IROOT/dart-sdk
+
+export PUB_CACHE=$IROOT/.pubcache
+
+export NGINX_HOME=$IROOT/nginx

+ 0 - 75
frameworks/Dart/dart-start/setup.py

@@ -1,75 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-
-def start(args, logfile, errfile):
-  setup_util.replace_text('dart-start/postgresql.yaml', 'host: .*', 'host: ' + args.database_host)
-  setup_util.replace_text('dart-start/mongodb.yaml', 'host: .*', 'host: ' + args.database_host)
-  try:
-    #
-    # install dart dependencies
-    #
-    subprocess.check_call('pub upgrade', shell=True, cwd='dart-start', stderr=errfile, stdout=logfile)
-    #
-    # start dart servers
-    #
-    for port in range(9001, 9001 + args.max_threads):
-      subprocess.Popen('dart server.dart -a 127.0.0.1 -p ' + str(port) + ' -d ' + str(args.max_concurrency / args.max_threads), shell=True, cwd='dart-start', stderr=errfile, stdout=logfile)
-    #
-    # create nginx configuration
-    #
-    conf = []
-    conf.append('worker_processes ' + str(args.max_threads) + ';')
-    conf.append('error_log /dev/null error;')
-    conf.append('events {')
-    conf.append('    worker_connections 1024;')
-    conf.append('}')
-    conf.append('http {')
-    conf.append('    access_log off;')
-    conf.append('    include /usr/local/nginx/conf/mime.types;')
-    conf.append('    default_type application/octet-stream;')
-    conf.append('    sendfile on;')
-    conf.append('    upstream dart_cluster {')
-    for port in range(9001, 9001 + args.max_threads):
-      conf.append('        server 127.0.0.1:' + str(port) + ';')
-    conf.append('        keepalive ' + str(args.max_concurrency / args.max_threads) + ';')
-    conf.append('    }')
-    conf.append('    server {')
-    conf.append('        listen 8080;')
-    conf.append('        location / {')
-    conf.append('            proxy_pass http://dart_cluster;')
-    conf.append('            proxy_http_version 1.1;')
-    conf.append('            proxy_set_header Connection "";')
-    conf.append('        }')
-    conf.append('    }')
-    conf.append('}')
-    #
-    # write nginx configuration to disk
-    #
-    with open('dart-start/nginx.conf', 'w') as f:
-      f.write('\n'.join(conf))
-    #
-    # start nginx
-    #
-    subprocess.Popen('sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf', shell=True, cwd='dart-start', stderr=errfile, stdout=logfile);
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-def stop(logfile, errfile):
-  #
-  # stop nginx
-  #
-  subprocess.check_call('sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf -s stop', shell=True, cwd='dart-start', stderr=errfile, stdout=logfile)
-  os.remove('dart-start/nginx.conf')
-  #
-  # stop dart servers
-  #
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'dart' in line and 'run-tests' not in line and 'run-ci' not in line:
-      pid = int(line.split(None, 2)[1])
-      os.kill(pid, 15)
-  return 0

+ 55 - 0
frameworks/Dart/dart-start/setup.sh

@@ -0,0 +1,55 @@
+#!/bin/bash
+
+sed -i 's|host: .*|host: '"${DBHOST}"'|g' postgresql.yaml
+sed -i 's|host: .*|host: '"${DBHOST}"'|g' mongodb.yaml
+
+$DART_HOME/bin/pub upgrade
+
+#
+# start dart servers
+#
+current=9001
+end=$(($current+$MAX_THREADS))
+while [ $current -lt $end ]; do
+  $DART_HOME/bin/dart server.dart -a 127.0.0.1 -p $current -d ${MAX_THREADS} &
+  let current=current+1
+done
+
+
+#
+# create nginx configuration
+#
+conf+="worker_processes ${MAX_THREADS};\n"
+conf+="error_log /dev/null error;\n"
+conf+="events {\n"
+conf+="\tworker_connections 1024;\n"
+conf+="}\n"
+conf+="http {\n"
+conf+="\taccess_log off;\n"
+conf+="\tinclude ${NGINX_HOME}/conf/mime.types;\n"
+conf+="\tdefault_type application/octet-stream;\n"
+conf+="\tsendfile on;\n"
+conf+="\tupstream dart_cluster {\n"
+current=9001
+end=$(($current+$MAX_THREADS))
+while [ $current -lt $end ]; do
+  conf+="\t\tserver 127.0.0.1:${current};\n"
+  let current=current+1
+done
+conf+="\t\tkeepalive ${MAX_THREADS};\n"
+conf+="\t}\n"
+conf+="\tserver {\n"
+conf+="\t\tlisten 8080;\n"
+conf+="\t\tlocation / {\n"
+conf+="\t\t\tproxy_pass http://dart_cluster;\n"
+conf+="\t\t\tproxy_http_version 1.1;\n"
+conf+="\t\t\tproxy_set_header Connection \"\";\n"
+conf+="\t\t}\n"
+conf+="\t}\n"
+conf+="}"
+#
+# write nginx configuration to disk
+#
+echo -e $conf > nginx.conf
+
+$NGINX_HOME/sbin/nginx -c $(pwd)/nginx.conf &

+ 7 - 0
frameworks/Dart/dart-stream/bash_profile.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+export DART_HOME=$IROOT/dart-sdk
+
+export PUB_CACHE=$IROOT/.pubcache
+
+export NGINX_HOME=$IROOT/nginx

+ 0 - 75
frameworks/Dart/dart-stream/setup.py

@@ -1,75 +0,0 @@
-import subprocess
-import sys
-import setup_util
-import os
-
-def start(args, logfile, errfile):
-  setup_util.replace_text('dart-stream/postgresql.yaml', 'host: .*', 'host: ' + args.database_host)
-  setup_util.replace_text('dart-stream/mongodb.yaml', 'host: .*', 'host: ' + args.database_host)
-  try:
-    #
-    # install dart dependencies
-    #
-    subprocess.check_call('$IROOT/dart-sdk/bin/pub upgrade', shell=True, cwd='dart-stream', stderr=errfile, stdout=logfile)
-    #
-    # start dart servers
-    #
-    for port in range(9001, 9001 + args.max_threads):
-      subprocess.Popen('dart server.dart -a 127.0.0.1 -p ' + str(port) + ' -d ' + str(args.max_concurrency / args.max_threads), shell=True, cwd='dart-stream', stderr=errfile, stdout=logfile)
-    #
-    # create nginx configuration
-    #
-    conf = []
-    conf.append('worker_processes ' + str(args.max_threads) + ';')
-    conf.append('error_log /dev/null error;')
-    conf.append('events {')
-    conf.append('    worker_connections 1024;')
-    conf.append('}')
-    conf.append('http {')
-    conf.append('    access_log off;')
-    conf.append('    include /usr/local/nginx/conf/mime.types;')
-    conf.append('    default_type application/octet-stream;')
-    conf.append('    sendfile on;')
-    conf.append('    upstream dart_cluster {')
-    for port in range(9001, 9001 + args.max_threads):
-      conf.append('        server 127.0.0.1:' + str(port) + ';')
-    conf.append('        keepalive ' + str(args.max_concurrency / args.max_threads) + ';')
-    conf.append('    }')
-    conf.append('    server {')
-    conf.append('        listen 8080;')
-    conf.append('        location / {')
-    conf.append('            proxy_pass http://dart_cluster;')
-    conf.append('            proxy_http_version 1.1;')
-    conf.append('            proxy_set_header Connection "";')
-    conf.append('        }')
-    conf.append('    }')
-    conf.append('}')
-    #
-    # write nginx configuration to disk
-    #
-    with open('dart-stream/nginx.conf', 'w') as f:
-      f.write('\n'.join(conf))
-    #
-    # start nginx
-    #
-    subprocess.Popen('sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf', shell=True, cwd='dart-stream', stderr=errfile, stdout=logfile);
-    return 0
-  except subprocess.CalledProcessError:
-    return 1
-
-def stop(logfile, errfile):
-  #
-  # stop nginx
-  #
-  subprocess.check_call('sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf -s stop', shell=True, cwd='dart-stream', stderr=errfile, stdout=logfile)
-  os.remove('dart-stream/nginx.conf')
-  #
-  # stop dart servers
-  #
-  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
-  out, err = p.communicate()
-  for line in out.splitlines():
-    if 'dart' in line and 'run-tests' not in line and 'run-ci' not in line:
-      pid = int(line.split(None, 2)[1])
-      os.kill(pid, 15)
-  return 0

+ 55 - 0
frameworks/Dart/dart-stream/setup.sh

@@ -0,0 +1,55 @@
+#!/bin/bash
+
+sed -i 's|host: .*|host: '"${DBHOST}"'|g' postgresql.yaml
+sed -i 's|host: .*|host: '"${DBHOST}"'|g' mongodb.yaml
+
+$DART_HOME/bin/pub upgrade
+
+#
+# start dart servers
+#
+current=9001
+end=$(($current+$MAX_THREADS))
+while [ $current -lt $end ]; do
+  $DART_HOME/bin/dart server.dart -a 127.0.0.1 -p $current -d ${MAX_THREADS} &
+  let current=current+1
+done
+
+
+#
+# create nginx configuration
+#
+conf+="worker_processes ${MAX_THREADS};\n"
+conf+="error_log /dev/null error;\n"
+conf+="events {\n"
+conf+="\tworker_connections 1024;\n"
+conf+="}\n"
+conf+="http {\n"
+conf+="\taccess_log off;\n"
+conf+="\tinclude ${NGINX_HOME}/conf/mime.types;\n"
+conf+="\tdefault_type application/octet-stream;\n"
+conf+="\tsendfile on;\n"
+conf+="\tupstream dart_cluster {\n"
+current=9001
+end=$(($current+$MAX_THREADS))
+while [ $current -lt $end ]; do
+  conf+="\t\tserver 127.0.0.1:${current};\n"
+  let current=current+1
+done
+conf+="\t\tkeepalive ${MAX_THREADS};\n"
+conf+="\t}\n"
+conf+="\tserver {\n"
+conf+="\t\tlisten 8080;\n"
+conf+="\t\tlocation / {\n"
+conf+="\t\t\tproxy_pass http://dart_cluster;\n"
+conf+="\t\t\tproxy_http_version 1.1;\n"
+conf+="\t\t\tproxy_set_header Connection \"\";\n"
+conf+="\t\t}\n"
+conf+="\t}\n"
+conf+="}"
+#
+# write nginx configuration to disk
+#
+echo -e $conf > nginx.conf
+
+$NGINX_HOME/sbin/nginx -c $(pwd)/nginx.conf &

+ 2 - 2
toolset/benchmark/framework_test.py

@@ -191,7 +191,7 @@ class FrameworkTest:
     #       use subprocess's cwd argument already
     previousDir = os.getcwd()
     os.chdir(os.path.dirname(self.troot))
-    logging.info("Running setup module start (cwd=%s)", os.path.dirname(self.troot))
+    logging.info("Running setup module start (cwd=%s)", os.path.dirname(self.directory))
     
     # Run the start script for the test as the "testrunner" user.
     # This requires superuser privs, so `sudo` is necessary.
@@ -246,7 +246,7 @@ class FrameworkTest:
     #       use subprocess's cwd argument already
     previousDir = os.getcwd()
     os.chdir(os.path.dirname(self.troot))
-    logging.info("Running setup module stop (cwd=%s)", os.path.dirname(self.troot))
+    logging.info("Running setup module stop (cwd=%s)", os.path.dirname(self.directory))
 
     # Meganuke
     try:

+ 2 - 2
toolset/setup/linux/webservers/nginx.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-RETCODE=$(fw_exists nginx.installed)
+RETCODE=$(fw_exists ${IROOT}/nginx.installed)
 [ ! "$RETCODE" == 0 ] || { return 0; }
 
 fw_get http://nginx.org/download/nginx-1.4.1.tar.gz
@@ -10,4 +10,4 @@ cd nginx-1.4.1
 make
 make install
 
-touch nginx.installed
+touch ${IROOT}/nginx.installed