/ lua

Lua and PM2

I've been using PM2[1] for quite some time now to manage services written in Lua.
How does that work you ask?

pm2 start server.lua --name "web" --interpreter luajit

Only downside? No live output in logs. Quite odd.
I started to hack io.stdout and it's metatable but quickly found the proper solution:


And with that you can use pm2 logs web to have a neat live feed.

  1. https://www.lua.org/manual/5.3/manual.html#pdf-file:setvbuf ↩︎ ↩︎