News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
Pages (3): « First [1] 2 3 Next > Last »
murgaLua CGI %ENV
Author Message
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #1
murgaLua CGI %ENV

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?

This post was last modified: 03-23-2008 06:43 AM by dvw86.

03-23-2008 06:42 AM
Find all posts by this user Quote this message in a reply
Juergen
Member
***


Posts: 81
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #2
RE: murgaLua CGI %ENV

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

03-23-2008 08:30 AM
Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #3
RE: murgaLua CGI %ENV

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?

03-23-2008 09:25 AM
Find all posts by this user Quote this message in a reply
Juergen
Member
***


Posts: 81
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #4
RE: murgaLua CGI %ENV

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

03-23-2008 09:48 AM
Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #5
RE: murgaLua CGI %ENV

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

03-23-2008 10:40 AM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #6
RE: murgaLua CGI %ENV

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

03-23-2008 08:17 PM
Visit this user's website Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #7
RE: murgaLua CGI %ENV

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

03-24-2008 03:39 AM
Find all posts by this user Quote this message in a reply
JohnMurga
Administrator
*******


Posts: 381
Group: Administrators
Joined: Apr 2007
Status: Offline
Reputation: 2
Post: #8
RE: murgaLua CGI %ENV

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

03-24-2008 04:04 AM
Visit this user's website Find all posts by this user Quote this message in a reply
dvw86
Junior Member
**


Posts: 39
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 0
Post: #9
RE: murgaLua CGI %ENV

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.

03-24-2008 06:29 AM
Find all posts by this user Quote this message in a reply
asafp
Member
***


Posts: 81
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #10
RE: murgaLua CGI %ENV

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.

03-24-2008 06:55 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pages (3): « First [1] 2 3 Next > Last »
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: