luarocks-site icon indicating copy to clipboard operation
luarocks-site copied to clipboard

what are those "${{DAEMON}}" directives in nginx.conf

Open teto opened this issue 1 year ago • 4 comments

I am trying to run luarocks-site locally (and make it easier for everyone https://github.com/luarocks/luarocks-site/pull/197) but I get invalid value "${{DAEMON}}" in "daemon" directive, it must be "on" or "off" in /home/user/luarocks-site/nginx.conf.compiled . There is a bunch of ${{XXX}} in the nginx.conf but it doesnt look like standard nginx variables, are these intended to be used with "substenv" ? another issue is that there is no "DAEMON" set anywhere in the repo so it makes starting the website even harder, I think one would need to commit a default .env with default values so that it's easier to get started

teto avatar Aug 14 '23 10:08 teto

This are interpolated by the lapis command when it starts up nginx. https://leafo.net/lapis/reference/getting_started.html#creating-an-application/nginx-configuration

The values are pulled from the lapis config for the environment the site was launched for. See config.moon

You should use Lapis to launch openresty, instead of calling the nginx executable directly. https://leafo.net/lapis/reference/command_line.html#command-reference/lapis-server

Regarding running the project locally, did you try following the instructions on the readme? https://github.com/luarocks/luarocks-site#how-to-run-locally

leafo avatar Aug 14 '23 17:08 leafo

This are interpolated by the lapis command when it starts up nginx. leafo.net/lapis/reference/getting_started.html#creating-an-application/nginx-configuration

oh thanks ! maybe the config files generated by lapis new should contain a header with # GENERATED BY LAPIS / run with lapis serve or have a nginx.conf.lapis extension to make it more prominent ? thanks for the link. I would like to change the valus of ${{NOTICE_LOG}} for instance (I start lapis serve in a systemd unit), I tried reading the lapis doc but was not sure how to do it. I feel like this is doable through "environment". I looked at app.moon that is created by lapis new but it doesnt contain NOTICE_LOG ? I also tried exporting LAPIS_NOTICE_LOG since I saw some LAPIS_XXX exports but to no avail.

EDIT: I was reading https://github.com/leafo/lapis/issues/612 which contained the answer I think: it's all in config.moon https://github.com/luarocks/luarocks-site/blob/master/config.moon#L19 It could be useful to have lapis --trace be more verbose and even support several log levels instead

Regarding running the project locally, did you try following the instructions on the readme? luarocks/luarocks-site#how-to-run-locally

Yes I did but I am trying to make something even easier to run (with declarative VMs).

The contributing part mentioned the usage of Google Cloud Storage. I've no experience with it, only with s3. Is there a way to fake google cloud storage locally ?

NB: while reading lapis doc, I realized you are itch.io's creator ?! much respect !

teto avatar Aug 14 '23 19:08 teto

EDIT: I was reading leafo/lapis#612 which contained the answer I think: it's all in config.moon https://github.com/luarocks/luarocks-site/blob/master/config.moon#L19

Perhaps it might be useful to slow down and spend a bit more time reading the relevant parts of the Lapis documentation, specifically about starting the server and configuration. I mentioned in the comment you replied to about config.moon. The documentation also talks about this. I would recommend going through the tutorial to write and start a empty app so you can be familiar with the basics of operation.

If you want to ask for help in real time you can try joining the MoonScript discord and someone can probably assist https://discord.com/invite/Y75ZXrD

It could be useful to have lapis --trace be more verbose and even support several log levels instead

lapis --trace has nothing to do with the configuration environment, but it shows the Lua stack trace if the lapis command fails with an error.

The contributing part mentioned the usage of Google Cloud Storage. I've no experience with it, only with s3. Is there a way to fake google cloud storage locally ?

Unfortunately I don't provide a file system stub that is a drop in replacement for cloud storage module. Uploading files is done directly to cloud storage to prevent additional work on the app server. It's not a trivial thing to replace.

Good luck

leafo avatar Aug 14 '23 23:08 leafo

I got the software starting, sudo -E lapis serve works until i run curl http://localhost:8080 where I get a nginx error "Failed to include SSI `intro.html" within a nix-shell provided by https://github.com/luarocks/luarocks-site/pull/197. It starts in "development mode"

ING "count", client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"
2024/01/23 00:28:27 [notice] 1205533#1205533: *1 [lua] postgres.lua:100: insert(): SQL: (4.32ms) INSERT INTO "exception_requests" ("exception_type_id", "msg", "trace", "ip", "updated_at", "path", "method", "created_at", "data") VALUES (1, './widgets/helpers.lua:11: Failed to include SSI `intro.html`', '
stack traceback:
	[C]: in function ''error''
	./widgets/helpers.lua:11: in function ''clone''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:324: in function ''call''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:361: in function ''write''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:340: in function ''write_escaped''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:195: in function ''call''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:361: in function ''write''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:340: in function ''write_escaped''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:195: in function ''call''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:361: in function ''write''
	...
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:195: in function ''clone''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:324: in function ''content''
	...m7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/html.lua:566: in function ''thing''
	...9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/request.lua:93: in function ''write''
	...9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/request.lua:252: in function ''render''
	...ua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/application.lua:191: in function <...ua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/application.lua:190>
	[C]: in function ''xpcall''
	...ua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/application.lua:214: in function ''dispatch''
	...7b9h-lua5.1-lapis-1.16.0-1/share/lua/5.1/lapis/nginx.lua:231: in function ''serve''
	content_by_lua(nginx.conf.compiled:50):1: in main chunk', '127.0.0.1', '2024-01-22 23:28:27', '/', 'GET', '2024-01-22 23:28:27', '{"params":{},"session":{},"request_uri":"\/","headers":{"accept":"*\/*","host":"localhost:8080","user-agent":"curl\/8.4.0"}}') RETURNING "id", "data", client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"

If I search from the root of luarocks-site, I get:

➜ fd -uuL intro
.luarocks/rocks-subdir/luasocket/3.1.0-1/docs/introduction.html
.luarocks/rocks-subdir/penlight/1.13.1-1/docs/manual/01-introduction.md.html
static/md/intro.html
static/md/intro.md

teto avatar Jan 22 '24 23:01 teto