Thoughts on Perl and Emacs, technology and writing

Plack and Auto-Restart

Okay, so down to business. One thing I like about straight cgi vs mod_perl is that any changes are immediately reflected on page refresh. And plackup (and twiggy) both offer an option to auto-restart when files change. Sounds good.

jared@win32 $ plackup -h
...
-r, --reload
Make plackup to watch updates from your development directory and
restarts the server whenever a file is updated. This option by
default watches the "lib" directory and the base directory where
*.psgi* file is located. Use "-R" if you want to watch other
directories.
...

Like this:

Related

7 Responses

It’d be much appreciated if you submit the bug report and patches to the issue tracker first http://github.com/miyagawa/Plack/issues before blogging it, since this post is now indexed on Google and people in the future might find this and thinks it’s broken even when it’s fixed.

Although Twiggy runs on AnyEvent which means it could run on any platforms supported by AE, stuff like signal handling, reloading and forking gets easily problematic on Win32 in general. I think HTTP::Server::Simple::PSGI and Shotgun is the easiest and safer combination to run on win32.

Also, the Filesys::Notify::Simple’s error on non-existent directory seems like only happens on win32. At least specifying one on my machine (OS X) doesn’t die like that. Patches are welcome to address that issue.

It’d be much appreciated if you submit the bug report and patches to the issue tracker first http://github.com/miyagawa/Plack/issues before blogging it, since this post is now indexed on Google and people in the future might find this and thinks it’s broken even when it’s fixed.

Noted for the future. I’m happy to update this post as and when this stuff gets fixed (although I checked github and… well, I’m not really familiar with github but I couldn’t tell if it has been fixed yet)

> Er, okay, -R only allows you to add paths. So there is not an obvious way of removing the paths that already exist. *sigh*

I read what you wrote here a couple of times and it still isn’t clear to me how to pass it the path to override. Anyway, nevermind, now that I know it is possible, I’ll try a couple of things (or read the code).

Although Twiggy runs on AnyEvent which means it could run on any platforms supported by AE, stuff like signal handling, reloading and forking gets easily problematic on Win32 in general. I think HTTP::Server::Simple::PSGI and Shotgun is the easiest and safer combination to run on win32.

Yeah, for sure Win32 is not my first choice OS, but unfortunately I often have little choice. And my current investigation of Plack is for something that will need to run on both Windows and Linux.

Also, the Filesys::Notify::Simple’s error on non-existent directory seems like only happens on win32. At least specifying one on my machine (OS X) doesn’t die like that. Patches are welcome to address that issue.

Right, nice hint! :)

# —

Anyway, seriously, thanks for the great work on this stuff. I guess it doesn’t get much testing on win32, but that’s fine. I wouldn’t work on it if I didn’t have to either :-/

About -R option, your inline example code didn’t pass the argument to -R itself — anyway, the -r or -R *does* add ‘lib’ relative to the .psgi file, which would cause issues like that on Windows apparently. Again, patches to Filesys::Notify::Simple is pretty much appreciated :)

Reporting on github is as easy as just creating an account and do it so on the web UI. If you don’t like to register you can also use the CPAN RT tracker which is just sending emails to bug-Plack at rt.cpan.org. (But i prefer github issue tracker, at least for now)

The Shotgun on Twiggy error is interesting as well but the error is so cryptic — usually not a type of errors you see as an end user program :/