Hi Konrad,
On Tue, 6 Mar 2012 12:46:44 +1100
Konrad Zielinski <[email protected]> wrote:
> Hi,
>
> At the moment I have my project in two files
>
> model.l which contains my domain classes, database init code and other
> related functions.
> server.l which contains my URL handling functions.
>
> I find that I'm constantly having to kill and restart the server
> process and then navigate to the code I'm working on. This is quite
> cumbersome.
>
> Is there a way to get the running picolisp process to detect and
> action changed source files without constant restarts.
>
> regs Konrad
>
You could just use the technique Alex uses, most of the code that
may need some quick tweak for each object is contained in a file that
is quickly 'loaded every time a request for that object arrives.
If you are careful designing the application you could make server.l
'load model.l again once in a while (maybe by "visiting" some secret
URL). if you have stuff in server.l that may change very often, move it
out to another module.
If you want to automatically detect a changed file and reload it, you
could code something like this, on Linux, using inotifywait(1) (I use
this code for synchronizing files between my shared host and my laptop
over ssh+rsync)
# Recursively watch the current directory
(setq *InotifyFD
(pipe
(call 'inotifywait "-mrq"
"-e" "modify,create,move,delete"
"." ) ) )
(de reload ()
# load modules, initialize variables, etc etc.
)
(task *InotifyFD
(in *InotifyFD
# The process died somehow, clean up.
(when (eof) (task *InotifyFD))
(line) # Eat notification.
# Wait 5 secs for the notifications to settle before reloading.
(alarm 5 (reload)) ) )
You could be more sophisticated reading the module name of the file
that changed, or preferably being more specific with which files to
watch, look at the manpage of inotifywait(1) for loads of more useful
info.
Cheers,
José
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe