|
@@ -3,7 +3,6 @@ import sys
|
|
import setup_util
|
|
import setup_util
|
|
import os
|
|
import os
|
|
|
|
|
|
-
|
|
|
|
def start(args, logfile, errfile):
|
|
def start(args, logfile, errfile):
|
|
setup_util.replace_text('dart-redstone/postgresql.yaml', 'host: .*', 'host: ' + args.database_host)
|
|
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)
|
|
setup_util.replace_text('dart-redstone/mongodb.yaml', 'host: .*', 'host: ' + args.database_host)
|
|
@@ -15,55 +14,12 @@ def start(args, logfile, errfile):
|
|
#
|
|
#
|
|
# start dart servers
|
|
# 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-redstone', 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-redstone/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-redstone', stderr=errfile, stdout=logfile);
|
|
|
|
|
|
+ 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
|
|
return 0
|
|
except subprocess.CalledProcessError:
|
|
except subprocess.CalledProcessError:
|
|
return 1
|
|
return 1
|
|
|
|
|
|
def stop(logfile, errfile):
|
|
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-redstone', stderr=errfile, stdout=logfile)
|
|
|
|
- os.remove('dart-redstone/nginx.conf')
|
|
|
|
#
|
|
#
|
|
# stop dart servers
|
|
# stop dart servers
|
|
#
|
|
#
|