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.
This commit is contained in:
2026-05-13 17:56:39 +01:00
parent 73efb42233
commit 4370b6ea99
+12
View File
@@ -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();