mongoose : how to "require" other module?

44 views
Skip to first unread message

冯力

unread,
Oct 29, 2013, 7:18:45 AM10/29/13
to mongoos...@googlegroups.com
 I have try to use lfs module. My test code is here:
--------------------------------------------------------------------------
<?
  mg.write('HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n')
  
  local l = require("lfs")
  for f in lfs.dir("/") do
     mg.write(f)
  end
?>
----------------------------------------------------------------------------
I have try to compile lfs to lfs.so,and put it in the same path with my code.
There is nothing in the browser,even when I delete the "require" line, there is nothing,not a error log.
In the terminal,it runs well like this:
----------------------------------------------
$lua admin.lua
HTTP/1.0 200 OK
Content-Type: text/html


dev
sys
etc
mnt
...
--------------------------------------------

the lfs.so is here:

$ ls
admin.lp  admin.lua  data  edit.lp  index.lp  js  lfs.so  list.lp  page.lp  test.lua

Who knows how to let it work? Millions of Thanks.

Ed Swift

unread,
Oct 31, 2013, 12:06:57 AM10/31/13
to mongoos...@googlegroups.com
The Lua include path is relative to the directory you were in when you launched Mongoose (the CWD), not relative to the Lua file that actually got served up. This is sort of unexpected if you're coming from CGI, and is on my personal list of things to bug Sergey about. Not sure if it's the problem you're having here, but it could be.

Sergey Lyubka

unread,
Nov 4, 2013, 6:53:45 PM11/4/13
to mongoose-users
As it is now, mongoose has lua statically compiled in.
That means, lua code cannot load DLLs, cause those DLLs have external
unresolved symbol (I think it is luaL_register() function) that is normally
exported by lua DLL.

To make things like LFS work, Lua must NOT be statically compiled in mongoose,
but be dynamically linked as DLL instead. I plan to provide a separate build
target for that, but it's not there yet. 


--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages