Browse Source

Nawak: limit number of workers for Travis

The number of postgresql connections available are currently limited with Travis.
Avoids hitting the "remaining connection slots are reserved for
non-replication superuser connections" error.
Erwan Ameil 10 years ago
parent
commit
248be32b00

+ 11 - 2
frameworks/Nimrod/nawak/app.nim

@@ -1,4 +1,4 @@
-import strtabs, strutils, math, algorithm
+import os, strtabs, strutils, math, algorithm
 import nawak_mongrel, jdump
 import nawak_mongrel, jdump
 import model, fortunes_tmpl
 import model, fortunes_tmpl
 when not defined(postgre_model) xor defined(redis_model):
 when not defined(postgre_model) xor defined(redis_model):
@@ -69,4 +69,13 @@ custom_page 404:
     return response(404, """Nah, I've got nothing.<br>
     return response(404, """Nah, I've got nothing.<br>
                             Here's a <b>404 Page Not Found</b> error for you.""")
                             Here's a <b>404 Page Not Found</b> error for you.""")
 
 
-run(init=init_db, nb_threads=256)
+var nb_workers = 32
+if paramCount() > 0:
+    try:
+        nb_workers = paramStr(1).parseInt
+    except ValueError:
+        echo "Usage: app [number of workers]"
+        echo "       Will start with 32 workers by default"
+echo "Starting with " & $nb_workers & " workers"
+
+run(init=init_db, nb_threads=nb_workers)

+ 6 - 1
frameworks/Nimrod/nawak/setup.py

@@ -19,7 +19,12 @@ def start(args, logfile, errfile):
   subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
   subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
   
   
   # launch workers
   # launch workers
-  subprocess.Popen("./nawak_postgre", shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
+  if os.environ.get("TRAVIS"):
+    nb_workers = 32
+  else:
+    nb_workers = 256
+  subprocess.Popen("./nawak_postgre " + nb_workers,
+                   shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
   return 0
   return 0
 
 
 def stop(logfile, errfile):
 def stop(logfile, errfile):

+ 6 - 1
frameworks/Nimrod/nawak/setup_redis.py

@@ -20,7 +20,12 @@ def start(args, logfile, errfile):
   subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
   subprocess.check_call("sudo m2sh start -name test", shell=True, cwd="nawak/conf", stderr=errfile, stdout=logfile)
   
   
   # launch workers
   # launch workers
-  subprocess.Popen("./nawak_redis", shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
+  if os.environ.get("TRAVIS"):
+    nb_workers = 32
+  else:
+    nb_workers = 256
+  subprocess.Popen("./nawak_redis " + nb_workers,
+                   shell=True, cwd="nawak", stderr=errfile, stdout=logfile)
   return 0
   return 0
 
 
 def stop(logfile, errfile):
 def stop(logfile, errfile):