You're missing
uv.run()
to start the event loop.
See also https://github.com/luvit/luvit/blob/master/init.lua#L47-L68 for
what Luvit does with regards to starting and cleaning up the event loop.
On Friday, July 7, 2017 at 2:02:33 PM UTC-7, develephant wrote:
>
> Hi,
>
> I have an server app that runs perfectly using:
>
> luvit /path/to/main.lua
>
> When the process starts, it sits and waits patiently for connections.
>
> I want to compile it into a standalone app, so I've made the needed
> adjustments to use *lit make* to do so. But, when running the app using
> Luvi, or compiling using Lit, the event loop seems to never "catch" and the
> app exits as soon as its started.
>
> Through debugging I can see that all of the proper areas are being hit,
> and the server object is present. Te be sure I wasn't totally nuts, I
> created a very simple `net` server, and the results are the same whether
> using *luvi* or *lit make*.
>
> The test project tree looks like:
>
> rootDir/
> libs
> main.lua
> luvit-loader.lua
> package.lua
>
>
> The package.lua contains:
>
> return {
> name = "develephant/project-name",
> version = "0.0.1",
> description = "A simple description of my little package.",
> tags = { "lua", "lit", "luvit" },
> license = "MIT",
> author = { name = "develephant", email = "<email>" },
> homepage = "https://github.com/develephant/project-name",
> luvi = {
> version = "v2.7.6",
> flavor = "regular",
> },
> dependencies = {
> "luvit/luvit"
> },
> files = {
> "**.lua",
> "!test*"
> }
> }
>
> I've created a simple test `main.lua` which looks like:
>
> local bundle = require('luvi').bundle
> loadstring(bundle.readfile("luvit-loader.lua"), "bundle:luvit-loader.lua"
> )()
>
> local net = require('net')
>
> local server = net.createServer(function(client)
> print("Client connected")
> end)
>
> server:on('error', function(err)
> if err then error(err) end
> end)
>
> server:listen(7173)
>
> When running the app with *luvit /path/to/main.lua* I need to comment out
> the first 2 lines (which makes sense), and it works great.
>
> But...when using *luvi ./path/to/app /path/to/bin/luvit* the app exits as
> soon as its started. If I use *luvi /path/to/bin/luvit ./path/to/app*
> then the Luvit REPL starts.
>
> When using *lit make ./path/to/app* it compiles without error, but again
> the event loop just doesn't seem to "catch" and the app exits.
>
> Again, I can see the server object using *p(server)*, but no luck on
> getting it to "listen" for connections.
>
> Any ideas on what I'm missing?
>
> Thanks in advance,
> -dev
>
>
>
--
You received this message because you are subscribed to the Google Groups
"luvit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.