murgaLua CGI %ENV
|
Author |
Message |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: murgaLua CGI %ENV
I am still here ...
Although I have been having a crazy time at work.
The last build in December may have had an embedded web-server (my current one does anyway).
I hope to tidy things up in the next couple of weeks and make another release. Other than web stuff I have added some SqLite utilities and multi-processing stuff.
Cheers
JohnM
|
|
05-28-2012 04:51 AM |
|
 |
jpjacobs
Member
  
Posts: 113
Group: Registered
Joined: Jul 2007
Status:
Offline
Reputation: 0
|
RE: murgaLua CGI %ENV
Nice to hear! I'm looking forward to testing it !
Kind regards,
Jan-Pieter
|
|
05-28-2012 07:35 AM |
|
 |
dvw86
Junior Member
 
Posts: 39
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
RE: murgaLua CGI %ENV
That sounds great. It was a bit of a challenge to get all the web server details worked out, so an embedded one would be fantastic. I am looking forward to it.
|
|
05-29-2012 01:55 AM |
|
 |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: murgaLua CGI %ENV
That sounds great. It was a bit of a challenge to get all the web server details worked out, so an embedded one would be fantastic. I am looking forward to it.
It's actually been there for months :-)
If you look at the RC build here :
http://murga-projects.com/forum/showthread.php?tid=418
You'll find a text web-server using the API in tests/http/example.lua
I guess I should have made a bigger deal of that :-)
Cheers
JohnM
|
|
05-30-2012 08:52 PM |
|
 |
dvw86
Junior Member
 
Posts: 39
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
RE: murgaLua CGI %ENV
Thanks,
I just got back from vacation and saw the last post. I will download it and give it a try.
|
|
06-02-2012 12:27 PM |
|
 |
dvw86
Junior Member
 
Posts: 39
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
RE: murgaLua CGI %ENV
Okay, I have a few questions off hand.
Here are the first few lines of the example.
#!/usr/bin/lua
local ctx = mg.start{
document_root = "./bindings/lua",
cgi_extensions = "lua",
cgi_interpreter = "/usr/bin/lua",
It looks like you are using Lua (not murgaLua?) and then you are starting the Mongoose web server and then you configure the web server settings. But again you are using lua instead of murgaLua. Are you re-naming murgaLua as "/usr/bin/lua"?
Here is what my Mongoose configuration file looks like when I use it on Windows with murgaLua as the cgi interpreter. I imagine that I could make the access_control_list a variable as well.
cgi_interpreter D:\windows\lua\murgaLua
cgi_extensions .lua
document_root D:\http-root
access_control_list -0.0.0.0/0,+127.0.0.1
|
|
06-02-2012 12:50 PM |
|
 |
JohnMurga
Administrator
      
Posts: 381
Group: Administrators
Joined: Apr 2007
Status:
Offline
Reputation: 2
|
RE: murgaLua CGI %ENV
It looks like you are using Lua (not murgaLua?) and then you are starting the Mongoose web server and then you configure the web server settings. But again you are using lua instead of murgaLua. Are you re-naming murgaLua as "/usr/bin/lua"?
The sad an honest response is that I did not test CGI ...
As I was interested in dealing with requests in-process.
As murgaLua is running Mongoose itself it can service the requests itself through callbacks. This means that it doesn't have to spawn a process each time and is much faster.
If you do want to use the CGI interpreter I suspect that line should read :
cgi_interpreter = murgaLua_ExePath,
I would appreciate some examples if you play with this :-)
Here is what my Mongoose configuration file looks like when I use it on Windows with murgaLua as the cgi interpreter. I imagine that I could make the access_control_list a variable as well.
Yes you can ...
In fact, here are the one you can set all of the following (I don't think num_threads will work though) :
cgi_extensions
cgi_environment
put_delete_passwords_file
cgi_interpreter
protect_uri
authentication_domain
ssi_extensions
access_log_file
ssl_chain_file
enable_directory_listing
error_log_file
global_passwords_file
index_files
enable_keep_alive
access_control_list
max_request_size
extra_mime_types
listening_ports
document_root
ssl_certificate
num_threads
run_as_user
This post was last modified: 06-02-2012 04:48 PM by JohnMurga.
|
|
06-02-2012 04:46 PM |
|
 |
dvw86
Junior Member
 
Posts: 39
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
RE: murgaLua CGI %ENV
Okay, that makes more sense. I would be happy to make up some examples and send them to you once it is working. I still am having issues though. Perhaps I am simply using it incorrectly. What I would like to do is have the user click on the lua file and have it start the web server, configure the web server and then launch a web browser pointing at the same script. I may need two scripts (one to launch web server and one to run the app), but wouldn't that launch two instances of murgaLua?
What I am currently doing is to have the web server always running as a stand alone process. The user simply points their web browser at the lua file and the app then runs in the web browser.
|
|
06-03-2012 04:48 AM |
|
 |
dvw86
Junior Member
 
Posts: 39
Group: Registered
Joined: Apr 2007
Status:
Offline
Reputation: 0
|
RE: murgaLua CGI %ENV
I'm not sure if this would help or not. This is a VB script I wrote but do not use. It uses QTWeb, Mongoose and murgaLua. I had the QTWeb home page set to the lua script that I wanted to run. It gave the functionality that I was looking for, but my wife wanted to use a Mac and I didn't want to re-write it. My goal would be to have this functionality all into one lua file along with the lua application that runs in the web browser.
Set WshShell = CreateObject("WScript.Shell")
'WScript.Echo WshShell.CurrentDirectory
'Find where this script is located.
Dim here
here = WshShell.CurrentDirectory
'Define where mongoose is.
Dim mongoose
mongoose = here & "\mongoose\mongoose"
'Define where the mongoose configuration file is.
Dim mongooseConf
mongooseConf = here & "\mongoose\mongoose.conf"
'Define the cgi_interpreter for the mongoose configuration file.
Dim cgi_interpreter
cgi_interpreter = "cgi_interpreter " & here & "\lua\murgaLua"
'Define the cgi_extensions for the mongoose configuration file.
Dim cgi_extensions
cgi_extensions = "cgi_extensions .lua"
'Define the path minus the windows directory.
Dim up
up = split(here,"windows")
Dim up1
up1 = up(0)
'Define the document_root for the mongoose configuration file.
Dim document_root
document_root = "document_root " + up1 + "views"
'Define the access_control_list for the mongoose configuration file.
Dim access_control_list
access_control_list = "access_control_list -0.0.0.0/0,+127.0.0.1"
'Define QtWeb.
Dim QtWeb
QtWeb = here & "\qtweb\QtWeb.exe"
'See what programs are running.
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")
'Loop though the list and see if mongoose is there.
For Each objProcess in colProcessList
'If mongoose is running mark it as true.
If objProcess.name = "MONGOOSE.EXE" then
mongooseFound = True
'This is in case mongoose.exe is in lowercase.
ElseIF objProcess.name = "mongoose.exe" then
mongooseFound = True
End if
Next
'If mongoose is running.
If mongooseFound = True then
'Let the user know that mongoose is already running.
'Msgbox("Mongoose is already running.")
'Start QtWeb.
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & QtWeb & Chr(34), 0
Set WshShell = Nothing
'If mongoose is not already running.
Else
'Write the mongoose.conf file.
Dim filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile(mongooseConf, True)
path = filesys.GetAbsolutePathName(mongooseConf)
getname = filesys.GetFileName(path)
filetxt.WriteLine(cgi_interpreter)
filetxt.WriteLine(cgi_extensions)
filetxt.WriteLine(document_root)
filetxt.WriteLine(access_control_list)
filetxt.Close
'If the mongoose.conf file was created.
If filesys.FileExists(path) Then
'WScript.Echo ("Your file, '" & getname & "', has been created.")
'Start mongoose
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & mongoose & Chr(34), 0
Set WshShell = Nothing
End If
'See what programs are running now.
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")
'Loop though the list again and see if mongoose is there.
For Each objProcess in colProcessList
' Unhide this to see a list of each process.
'Msgbox(objProcess.name)
'If mongoose is running mark it as true.
If objProcess.name = "MONGOOSE.EXE" then
mongooseFound1 = True
'This is in case mongoose.exe is in lowercase.
ElseIF objProcess.name = "mongoose.exe" then
mongooseFound1 = True
End if
Next
'If mongoose is running.
If mongooseFound1 = True then
'Let the user know that mongoose is running.
'Msgbox("Mongoose is now running.")
'Start QtWeb.
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & QtWeb & Chr(34), 0
Set WshShell = Nothing
'Run this check as long as mongoose or QtWeb is running.
While 0 = 0
'Define mongooseFound2 and set it as false.
mongooseFound2 = False
'Define QtWebFound and set it as false.
QtWebFound = False
'Set a 2 second delay between checks.
Set WshShell = CreateObject("WScript.Shell")
wscript.sleep 2000
'See what programs are running now.
Set colProcessList = GetObject("Winmgmts:").ExecQuery ("Select * from Win32_Process")
'Loop though the list and see what is there.
For Each objProcess in colProcessList
'If mongoose is running mark it as true.
If objProcess.name = "MONGOOSE.EXE" then
mongooseFound2 = True
'This is in case mongoose.exe is in lowercase.
ElseIF objProcess.name = "mongoose.exe" then
mongooseFound2 = True
'If QtWeb is running mark it as true.
ElseIf objProcess.name = "QtWeb.exe" Then
QtWebFound = True
End If
Next
'If mongoose was killed, then kill QtWeb.
If mongooseFound2 = False Then
'Let the user know that this app is about to stop.
Msgbox("Stopping Mongoose will kill this application!")
'Open up a shell and kill QtWeb.
WshShell.Run ("C:\Windows\system32\cmd.exe")
' I added sleep to fix a problem
wscript.sleep 50
WshShell.sendkeys "taskkill /IM QtWeb.exe"
wscript.sleep 50
WshShell.SendKeys "{ENTER}"
'Now kill the shell.
wscript.sleep 50
WshShell.sendkeys "taskkill /IM cmd.exe"
wscript.sleep 50
WshShell.SendKeys "{ENTER}"
'Exit from the VB Script.
WScript.Quit [exitcode]
'If mongoose is running but QtWeb has been killed, stop mongoose.
ElseIf QtWebFound = False Then
'Msgbox("QtWeb has been Stoped!")
'Open up a shell and kill mongoose.
WshShell.Run ("C:\Windows\system32\cmd.exe")
' I Add sleep to fix the problem :d
wscript.sleep 50
WshShell.sendkeys "taskkill /F /IM mongoose.exe"
wscript.sleep 50
WshShell.SendKeys "{ENTER}"
wscript.sleep 50
WshShell.sendkeys "taskkill /F /IM MONGOOSE.EXE"
wscript.sleep 50
WshShell.SendKeys "{ENTER}"
'Now kill the sell.
wscript.sleep 50
WshShell.sendkeys "taskkill /IM cmd.exe"
wscript.sleep 50
WshShell.SendKeys "{ENTER}"
'Exit from the VB Script.
WScript.Quit [exitcode]
End If
Set WshShell = Nothing
Wend
'If mongoose did not start.
Else
Msgbox("Could not start Mongoose.")
'End if mongoose is running (second check).
End If
'End if mongoose is running (first check).
End If
This post was last modified: 06-03-2012 05:16 AM by dvw86.
|
|
06-03-2012 05:13 AM |
|
 |
|