Hello!
On Tue, Jan 7, 2014 at 7:00 PM, develephant.net wrote:
> I've been reading through the docs and examples, and I can't seem to fully
> wrap my head around how a socket server would work with OpenResty being HTTP
> based on nginx.
>
Yes, OpenResty has been focusing on HTTP. But there has been a plan to
add support for pure TCP downstream. bigplum in the community has done
some attempts like this:
https://github.com/bigplum/nginx-tcp-lua-module
And I'm going to integrate such a ngx_tcp_lua module into OpenResty soon.
In the meantime, you can use websockets as a work-around, just as
Brian Akins has pointed out :)
> From what I have seen so far I assume something like this:
>
[...]
>
> Now I know that's not a realistic app, but I am wondering if that's the
> general direction.
Yes, it is the supposed way of running the server. It is also demonstrated here:
http://openresty.org/#Samples
> Most importantly, how does this work in a non web based
> environment? I would be connecting with luasocket from a Lua mobile client
> to the OpenResty app instance, not through a web client.
If you mean using OpenResty to write a standalone console-based client
program, then we'll have a "ngxlua" utility program in OpenResty soon.
You'll be able to run non-server programs like this:
$ ngxlua myclient.lua
And no ports and no socket files will be listened.
> I also would like
> to keep all functionality in external Lua files as opposed to the config
> file.
>
For servers not based on the upcoming "ngxlua" utility mentioned
above, it requires and will still require a configuration file. You
can have a fixed configuration file for your app, just like
PHP/Python/Perl/Ruby web apps often have a relatively fixed nginx
configuration file. We can add support for pure Lua configuration
files to nginx in the future. But it is still a configuration file.
Best regards,
-agentzh