Browse Source

Merge pull request #1045 from hamiltont/lapis-949

Lua: Cleanup all
Hamilton Turner 11 years ago
parent
commit
bf18dc0f91

+ 3 - 1
frameworks/Lua/lapis/install.sh

@@ -1,3 +1,5 @@
 #!/bin/bash
 
-fw_depends lapis nginx openresty
+fw_depends lua nginx openresty
+
+sudo luarocks install https://raw.githubusercontent.com/leafo/lapis/master/lapis-dev-1.rockspec

+ 1 - 0
frameworks/Lua/lapis/nginx.conf

@@ -13,6 +13,7 @@
         variables_hash_max_size 1024;
         access_log off;
         include mime.types;
+        lua_package_path 'CWD/?.lua;;';
 
         upstream database {
             postgres_server DBHOSTNAME dbname=hello_world user=benchmarkdbuser password=benchmarkdbpass;

+ 3 - 2
frameworks/Lua/lapis/web.lua

@@ -20,9 +20,10 @@ do
   local _obj_0 = table
   sort = _obj_0.sort
 end
-local random
+local min, random
 do
   local _obj_0 = math
+  min = _obj_0.min
   random = _obj_0.random
 end
 local Fortune
@@ -177,7 +178,7 @@ do
         num_queries = 1
       end
       local worlds = { }
-      for i = 1, num_queries do
+      for i = 1, min(500, num_queries) do
         local wid = random(1, 10000)
         local world = World:find(wid)
         world.randomnumber = random(1, 10000)

+ 2 - 2
frameworks/Lua/lapis/web.moon

@@ -4,7 +4,7 @@ import Model from require "lapis.db.model"
 import config from require "lapis.config"
 import insert from table
 import sort from table
-import random from math
+import min, random from math
 
 class Fortune extends Model
 
@@ -55,7 +55,7 @@ class Benchmark extends lapis.Application
     if num_queries == 0
       num_queries = 1
     worlds = {}
-    for i = 1, num_queries
+    for i = 1, min(500, num_queries)
       wid = random(1, 10000)
       world = World\find wid
       world.randomnumber = random(1, 10000)

+ 13 - 1
frameworks/Lua/leda/install.sh

@@ -1,3 +1,15 @@
 #!/bin/bash
 
-fw_depends leda
+fw_depends lua
+
+sudo luarocks install lua-cjson
+
+wget -O leda.tar.gz http://sergeyzavadski.github.io/leda/releases/leda-0.5.4/leda-0.5.4.tar.gz 
+fw_untar leda.tar.gz
+cd leda-0.5.4
+
+./configure
+make 
+sudo make install
+cd .. 
+mv leda-0.5.4 leda

+ 1 - 1
frameworks/Lua/openresty/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends openresty nginx
+fw_depends lua nginx openresty 

+ 1 - 1
frameworks/Lua/openresty/nginx.conf

@@ -8,7 +8,7 @@ events {
 http {
     resolver 127.0.0.1;
     access_log off;
-    lua_package_path '/home/tfb/FrameworkBenchmarks/openresty/?.lua;;';
+    lua_package_path 'CWD/?.lua;;';
     init_by_lua 'require "resty.core" encode = require("cjson").encode mysql = require("resty.mysql")';
     server {
         listen       8080;

+ 3 - 3
frameworks/Lua/openresty/setup.py

@@ -4,13 +4,13 @@ import setup_util
 import os
 
 def start(args, logfile, errfile):
-  setup_util.replace_text("openresty/nginx.conf", "CWD", os.getcwd())
+  setup_util.replace_text("openresty/nginx.conf", "CWD", args.troot)
   setup_util.replace_text("openresty/app.lua", "DBHOSTNAME", args.database_host)
-  subprocess.Popen('sudo /usr/local/openresty/nginx/sbin/nginx -c `pwd`/nginx.conf -g "worker_processes ' + str((args.max_threads)) + ';"', shell=True, cwd="openresty", stderr=errfile, stdout=logfile)
+  subprocess.Popen('sudo /usr/local/openresty/nginx/sbin/nginx -c $TROOT/nginx.conf -g "worker_processes ' + str((args.max_threads)) + ';"', shell=True, cwd="openresty", stderr=errfile, stdout=logfile)
 
   return 0
 
 def stop(logfile, errfile):
-  subprocess.Popen('sudo /usr/local/openresty/nginx/sbin/nginx -c `pwd`/nginx.conf -s stop', shell=True, cwd="openresty", stderr=errfile, stdout=logfile)
+  subprocess.Popen('sudo /usr/local/openresty/nginx/sbin/nginx -c $TROOT/nginx.conf -s stop', shell=True, cwd="openresty", stderr=errfile, stdout=logfile)
 
   return 0

+ 0 - 23
toolset/setup/linux/frameworks/leda.sh

@@ -1,23 +0,0 @@
-#!/bin/bash
-
-RETCODE=$(fw_exists leda)
-[ ! "$RETCODE" == 0 ] || { return 0; }
-
-rm -rf leda || true
-
-sudo apt-get install -y  g++
-sudo apt-get install -y  luarocks
-
-sudo luarocks install lua-cjson
-
-
-wget -O leda.tar.gz http://sergeyzavadski.github.io/leda/releases/leda-0.5.4/leda-0.5.4.tar.gz 
-fw_untar leda.tar.gz
-cd leda-0.5.4
-
-./configure
-make 
-sudo make install
-cd .. 
-mv leda-0.5.4 leda
-

+ 14 - 0
toolset/setup/linux/languages/lua.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+RETCODE=$(fw_exists lua.installed)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+# Eventually, we should also install lua5.2 and luajit
+#
+# At the moment they seem to cause issues with lapis 
+# being able to compile. Since no Lua test is using 
+# either luajit or lua5.2 at the moment I have just
+# left them out
+sudo apt-get install -y lua5.1 luarocks
+
+touch lua.installed

+ 8 - 4
toolset/setup/linux/webservers/openresty.sh

@@ -1,12 +1,16 @@
 #!/bin/bash
 
-RETCODE=$(fw_exists /usr/local/openresty/nginx/sbin/nginx)
+RETCODE=$(fw_exists openresty.installed)
 [ ! "$RETCODE" == 0 ] || { return 0; }
 
-fw_depends nginx
+fw_depends nginx lua
+
 fw_get http://openresty.org/download/ngx_openresty-1.5.12.1.tar.gz
 fw_untar ngx_openresty-1.5.12.1.tar.gz
+
 cd ngx_openresty-1.5.12.1
-./configure --with-luajit-xcflags=-DLUAJIT_NUMMODE=2 --with-cc-opt=-O2 --with-http_postgres_module -j2
-make -j2
+./configure --with-luajit-xcflags=-DLUAJIT_NUMMODE=2 --with-cc-opt=-O2 --with-http_postgres_module -j4
+make -j4
 sudo make install
+
+touch $IROOT/openresty.installed