Here's a little snippet that will start a background thread that checks mtimes of a specified list of files, if any one changes then it will be reloaded in the background. I find this very useful to put right before I call (asv) so that as I develop I can just leave the server running. (def reload-check (paths (o mtimes (table)))
(sleep 5)
(map [if (no (mtimes _))
(= (mtimes _) (mtime _))
(no (is (mtimes _) (mtime _)))
(do
(= (mtimes _) (mtime _))
(load _))]
paths)
(reload-check paths mtimes))
And then: (def csv ()
(prn "starting chat server")
(thread (reload-check '("chat.arc")))
(asv))
|