xyproto / algernon

Small self-contained pure-Go web server with Lua, Teal, Markdown, Ollama, HTTP/2, QUIC, Redis, SQLite and PostgreSQL support ++
https://algernon.roboticoverlords.org
BSD 3-Clause "New" or "Revised" License
2.82k stars 138 forks source link

Lua init script #103

Open linkerlin opened 2 years ago

linkerlin commented 2 years ago

How about added a init.lua for algernon initial?

linkerlin commented 2 years ago

Maybe algernon can be a bettery-included soulution for lua programmers.

xyproto commented 2 years ago

Algernon does support initial Lua scripts, for instance serverconf.lua or /etc/algernon/server.lua. Is this what you had in mind, or does init.lua imply something else?

Algernon coming with everything a Lua programmer would need to create a web application is a goal, yes.

tooolbox commented 2 years ago

@xyproto in this vein, one thing I discovered while adding Teal support is that it seems like new Lua states are spun up without having serverconf.lua run on them. I.e., only the first state created executes that script while subsequent ones generated for the state pool are virgin.

This makes a degree of sense, because serverconf.lua sets configuration for the server and you probably don't want those things re-running every time Algernon adds to the Lua state pool. But it also means you have no hook to reliably initialize every Lua state that is created.

I could be wrong on this, feel free to set me straight. Also, I have no specific need for this feature at this time, just commenting on the above.