Self-reloading Continuity daemons

scrottie on 2007-05-19T02:27:47

async { my $timer = Coro::Event->timer( interval => 2, ); my $mod_time = -M __FILE__; while(1) { $timer->next; if(-M __FILE__ != $mod_time) { $mod_time = -M __FILE__; Storable::nstore { board => $board, players => $players, }, "$0.store"; STDERR->print("Exec-ing self!\n\n"); exec '/usr/bin/perl', __FILE__ or warn $!; } } };

On startup, it initializes its two main objects from the .store file.

Saving from vi causes it to immediately reload itself.

Wee!

-scott