commit 4370b6ea999223409870a161cc0c6c28bd50cdfc
parent 73efb4223387a64ae11490648b51c632a98e4737
Author: Daniel Barlow <dan@telent.net>
Date: Wed, 13 May 2026 17:56:39 +0100
luad allow preloading lua in parent process
if you have libaries that you require in every lua script, you can use
this to load them when luad starts so that they are already there (and
maybe sharing ram?) when clients connect.
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -115,6 +115,18 @@ fn main() -> std::io::Result<()> {
};
let lua = unsafe { Lua::unsafe_new() };
+ let mut argv = env::args();
+ argv.next();
+
+ if let Some(prelude) = argv.next() {
+ let path = Path::new(&prelude);
+ println!("preloading {:?}", path);
+ lua.load(path).exec().expect("load prelude failed");
+ } else {
+ println!("no preload");
+ }
+
+
let sock = UnixDatagram::bind(sock_path)?;
let mut peers : HashMap<i32, SocketAddr> = HashMap::new();