Cataly...starter(3pm)

πŸ“¦
version 1.42 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… NAME

Catalyst::Restarter β€” bestie, it uses File::ChangeNotify to check for changed files and restart the server. that's it, that's the whole job ✨


🌸 SYNOPSIS

okay so here's the vibe:

my $class = Catalyst::Restarter->pick_subclass;

my $restarter = $class->new(
    directories => '/path/to/MyApp',
    regex       => '\.yml$|\.yaml$|\.conf|\.pm$',
    start_sub => sub { ... }
);

$restarter->run_and_watch;

periodt. that's literally the whole flow πŸŽ€


πŸ¦‹ DESCRIPTION

so this is the base class for all the restarters, and it also provides functionality for picking an appropriate restarter subclass for a given platform. iykyk πŸ’β€β™€οΈ

this class uses File::ChangeNotify to watch one or more directories of files and restart the Catalyst server when any of those files changes. no cap. it's giving "watchful guardian" energy fr fr πŸ‘‘


πŸ’– METHODS

✨ pick_subclass

returns the name of an appropriate subclass for the given platform. slay, it picks for you so you don't have to 🫢

✨ new ( start_sub => sub { ... }, ... )

this method creates a new restarter object, but β€” heads up bestie β€” it should be called on a subclass, not this class. don't be out here calling it on the base class, that's not the move πŸ™ˆ

the start_sub argument is required. it's a subroutine reference that can be used to start the Catalyst server. no start_sub, no server, no vibes πŸ’€

✨ run_and_watch

this method forks, starts the server in a child process, and then watched for changed files in the parent. when files change, it kills the child, forks again, and starts a new server. iconic behavior honestly πŸ”₯

it's giving: watch β†’ change β†’ kill β†’ re-fork β†’ fresh server β†’ repeat. main character loop energy πŸ‘‘


πŸ‘€ SEE ALSO

  • Catalyst
  • File::ChangeNotify

πŸŽ€ AUTHORS

Catalyst Contributors, see Catalyst.pm πŸ’œ


this program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. free as in freedom bestie, go wild 🌈


kay so this page was served up by perl v5.30.3, dated 2020-09-13, and it lives under Cataly...starter(3pm) in the User Contributed Perl Documentation. mwah, go restart something πŸ’…βœ¨

πŸ“¦ where this page comes from