Browse Source

Merge pull request #2507 from TechEmpower/fix-lua

Fixes the hostname issues with Lua
Mike Smith 8 years ago
parent
commit
2c29193914

+ 1 - 1
frameworks/Lua/lapis/config.lua

@@ -14,6 +14,6 @@ return config({
     database("hello_world")
     database("hello_world")
     user("benchmarkdbuser")
     user("benchmarkdbuser")
     password("benchmarkdbpass")
     password("benchmarkdbpass")
-    return host("DBHOSTNAME")
+    return host(os.getenv("DBHOST"))
   end)
   end)
 end)
 end)

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

@@ -16,7 +16,7 @@
         lua_package_path 'CWD/?.lua;;';
         lua_package_path 'CWD/?.lua;;';
 
 
         upstream database {
         upstream database {
-            postgres_server DBHOSTNAME dbname=hello_world user=benchmarkdbuser password=benchmarkdbpass;
+            postgres_server TFB-database dbname=hello_world user=benchmarkdbuser password=benchmarkdbpass;
         }
         }
         init_by_lua 'require "resty.core"; lapis = require "lapis.init"';
         init_by_lua 'require "resty.core"; lapis = require "lapis.init"';
         server {
         server {

+ 0 - 4
frameworks/Lua/lapis/setup.sh

@@ -1,9 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
-sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' config.lua
-sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' config.moon
-sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' nginx.conf
-
 fw_depends postgresql lua luarocks openresty
 fw_depends postgresql lua luarocks openresty
 
 
 luarocks install lapis
 luarocks install lapis

+ 1 - 1
frameworks/Lua/octopus/config.lua

@@ -21,7 +21,7 @@ return {
 	
 	
 	databaseConnection = {
 	databaseConnection = {
 		rdbms       =   "mysql",
 		rdbms       =   "mysql",
-		host        =   "DBHOSTNAME",
+		host        =   os.getenv("DBHOST"),
 		port        =   3306, 
 		port        =   3306, 
 		database    =   "hello_world",
 		database    =   "hello_world",
 		user        =   "benchmarkdbuser",
 		user        =   "benchmarkdbuser",

+ 1 - 2
frameworks/Lua/octopus/setup.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 
 
-fw_depends mysql
+fw_depends mysql lua
 
 
 rm -rf octopus
 rm -rf octopus
 git clone https://github.com/cyberz-eu/octopus.git
 git clone https://github.com/cyberz-eu/octopus.git
@@ -11,7 +11,6 @@ cd ..
 
 
 cp -avr app octopus/extensions
 cp -avr app octopus/extensions
 cp -vf config.lua octopus/extensions
 cp -vf config.lua octopus/extensions
-sed -i 's|DBHOSTNAME|'"${DBHOST}"'|g' octopus/extensions/config.lua
 
 
 cd octopus/bin/unix
 cd octopus/bin/unix
 . ./server.sh install
 . ./server.sh install

+ 1 - 1
frameworks/Lua/openresty/app.lua

@@ -13,7 +13,7 @@ template.caching(false)
 local view = template.compile([[<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>{% for _,f in ipairs(fortunes) do %}<tr><td>{{ f.id }}</td><td>{{ f.message }}</td></tr>{% end %}</table></body></html>]], nil, true)
 local view = template.compile([[<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>{% for _,f in ipairs(fortunes) do %}<tr><td>{{ f.id }}</td><td>{{ f.message }}</td></tr>{% end %}</table></body></html>]], nil, true)
 
 
 local mysqlconn = {
 local mysqlconn = {
-	host = "DBHOSTNAME",
+	host = os.getenv("DBHOST"),
 	port = 3306,
 	port = 3306,
 	database = "hello_world",
 	database = "hello_world",
 	user = "benchmarkdbuser",
 	user = "benchmarkdbuser",

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

@@ -27,5 +27,7 @@ echo -e "export PATH=\$LUA_HOME/bin:\$PATH" >> $IROOT/lua.installed
 # TODO: This feels very hackish
 # TODO: This feels very hackish
 echo -e 'export LUA_PATH="./?.lua;./?.lc;$LUA_HOME/share/lua/5.1/?/init.lua;$LUA_HOME/share/lua/5.1/?.lua;$LUA_HOME/lib/lua/5.1/?/init.lua;$LUA_HOME/lib/lua/5.1/?.lua"' >> $IROOT/lua.installed
 echo -e 'export LUA_PATH="./?.lua;./?.lc;$LUA_HOME/share/lua/5.1/?/init.lua;$LUA_HOME/share/lua/5.1/?.lua;$LUA_HOME/lib/lua/5.1/?/init.lua;$LUA_HOME/lib/lua/5.1/?.lua"' >> $IROOT/lua.installed
 echo -e 'export LUA_CPATH="./?.lua;./?.lc;$LUA_HOME/share/lua/5.1/?/init.so;$LUA_HOME/share/lua/5.1/?.so;$LUA_HOME/lib/lua/5.1/?/init.so;$LUA_HOME/lib/lua/5.1/?.so"' >> $IROOT/lua.installed
 echo -e 'export LUA_CPATH="./?.lua;./?.lc;$LUA_HOME/share/lua/5.1/?/init.so;$LUA_HOME/share/lua/5.1/?.so;$LUA_HOME/lib/lua/5.1/?/init.so;$LUA_HOME/lib/lua/5.1/?.so"' >> $IROOT/lua.installed
+# This helps the fact that Lua/nginx cannot resolve hostnames from /etc/hosts
+echo -e "export DBHOST=`getent hosts TFB-database | awk '{ print $1 }'`" >> $IROOT/lua.installed
 
 
 source $IROOT/lua.installed
 source $IROOT/lua.installed