Murga-Projects Forums

Full Version: murgaLua CGI %ENV
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using Pupeee Beta 4 (based on Puppy Linux 3.01), the latest Monkey Web Sever, and murgaLua as a CGI language. This works well but i can't figure out how to call the system variables for the CGI. In Perl you can get them like this:

Code:
print "Caller = $ENV{HTTP_REFERER}\n";

Does anybody know how to call them in murgaLua?

That would be

Code:
print("Caller = "..os.getenv("HTTP_REFERER"))


But you shouldn't use murgaLua for CGI scripts. murgaLua is packed and has therefore more than an order of magnitude startup overhead (on my system it is more then 30x compared to stock lua5.1). Since there is nothing in murgaLua that isn't available elsewhere (except for the fltk bindings, which I guess you don't want to use in a CGI script ;-) there is no reason to use murgaLua for CGI scripts.

If you want to use it anyhow, it might make sense to unpack it (if the CGI script isn't only called once in a while) with "upx -d murgaLua". This way there is only a 8x startup overhead (on my system). Of course this applies to hot caches. With a cold cache the overhead might be smaller, due to the reduced binary size.

Juergen

Juergen Wrote:
That would be

Code:
print("Caller = "..os.getenv("HTTP_REFERER"))


But you shouldn't use murgaLua for CGI scripts. murgaLua is packed and has therefore more than an order of magnitude startup overhead (on my system it is more then 30x compared to stock lua5.1). Since there is nothing in murgaLua that isn't available elsewhere (except for the fltk bindings, which I guess you don't want to use in a CGI script ;-) there is no reason to use murgaLua for CGI scripts.

If you want to use it anyhow, it might make sense to unpack it (if the CGI script isn't only called once in a while) with "upx -d murgaLua". This way there is only a 8x startup overhead (on my system). Of course this applies to hot caches. With a cold cache the overhead might be smaller, due to the reduced binary size.

Juergen


Thank you. The reason I was going to use murgaLua was two-fold. It is already in Pupeee and it can access/modify SQLite databases. Lua is so small that I don't mind installing another copy of it, but would it have SQLite support?

dvw86 Wrote:
Thank you. The reason I was going to use murgaLua was two-fold. It is already in Pupeee and it can access/modify SQLite databases. Lua is so small that I don't mind installing another copy of it, but would it have SQLite support?

There are multiple SQL database and SQLite bindings for Lua.
http://www.keplerproject.org/
http://luaforge.net/

Have a good selection of interesting Lua modules.
murgaLua uses this SQLite binding: http://luaforge.net/projects/luasqlite/

Juergen

Thanks Juergen. If I get serious about it I may install another version of Lua but for just playing around murgaLua should work. It doesn't appear to put much of a load on my computer and is still fast. Your help was much appreciated Smile

Juergen Wrote:
But you shouldn't use murgaLua for CGI scripts. murgaLua is packed and has therefore more than an order of magnitude startup overhead (on my system it is more then 30x compared to stock lua5.1). Since there is nothing in murgaLua that isn't available elsewhere (except for the fltk bindings, which I guess you don't want to use in a CGI script ;-) there is no reason to use murgaLua for CGI scripts.

If you want to use it anyhow, it might make sense to unpack it (if the CGI script isn't only called once in a while) with "upx -d murgaLua". This way there is only a 8x startup overhead (on my system). Of course this applies to hot caches. With a cold cache the overhead might be smaller, due to the reduced binary size.


Not really a fair comparison as once you incorporate the relevant bindings to stock lua the startup time will increase too... Although if you are going to use murgaLua for CGI you probably should unpack it.

FYI, the XML bindings and a few other bits and pieces are also not available elsewhere ;-)

BTW, I'd like to see a test to prove your 30% file overhead claim from an earlier post.

Cheers
JohnM

Ok tell me more about unpacking it. What will that do to the size? Since I am using it in Pupeee I am concerned about keeping it small. Also will that affect my other murgaLua scripts and applications? Good to see a new version out Smile
If you are using murgaLua for CGI then you invoke it each time a script is run, that means that you have to wait for it to start up ... And by default murgaLua is packed with UPX, which means that you have to wait a bit longer, as the executable itself is compressed and has to decompress.

As Juergen indicated you can use UPX to unpack it, and that should make it faster (although the executable will be well over twice the size).

One way around this would be to write a web-server in murgaLua capable of running murgaLua cgi scripts ... Either than the fact that script execution would be single threaded it would be pretty easy and avoid the startup issues mentioned here. Writing this web-server is on my todo list, as I'd like to include it in the murgaLua runtime.

Cheers
JohnM
Thanks for the info John. I don't really notice any delay so I will leave it the way it is for now. Writing a web server in murgaLua sounds like a time consuming task.
In my opinion, murgaLua has tremendous potential as a web scripting language. This is not really my area of expertise, but it seems that Perl and PHP dominate that realm mainly out of tradition. Those languages are certainly capable of powering some industrial strength applications, but I just don't like them (a topic for another post on another forum some other time). Some people don't even know that a web server application can be written in any programming language. Some web hosting companies restrict you to PHP and Perl.

Then there is ASP. I don't know much about it, but it seems like shooting an ant with an elephant gun.

Ruby on Rails might be on to something. I've always liked the concept of separating data storage, data presentation, and processing logic. The Rails model might be a good place to start for anyone looking to move murgaLua in this direction.

Just my two cents worth.
Pages: 1 2 3
Reference URL's