++ed by:
NEYASOV AWNCORP JNBEK NEMUX

4 PAUSE users
3 non-PAUSE users.

Jan Henning Thorsen

NAME

Toadfarm::Plugin::Reload - Reload toadfarm with new code

DESCRIPTION

This Mojolicious plugin allows the "Toadfarm" server to restart when a resource is hit with a special JSON payload. The payload needs to be compatible with the post-receive-hook github use.

SETUP

  • You need to set up a post receive hook on github to make this reloader work. Go to "https://github.com/YOUR-USERNAME/YOUR-REPO/settings/hooks" to set it up.

  • The WebHook URL needs to be "http://yourserver.com/some/secret/path" and should not trigger any of the mounted apps.

SYNOPSIS

  #!/usr/bin/env perl
  use Toadfarm -init;

  # mount applications, set up logging, ...

  plugin "Toadfarm::Plugin::Reload" => {
    path         => "/some/private/path",
    repositories => [
      {
        name   => "cool-repo",
        branch => "some-branch",
        path   => "/path/to/cool-repo",
        remote => "whatever",           # default="origin"
      },
    ],
  };

  start;

Configuration details:

  • path

    This should be the path part of the URL to POST data to reload the server. Make this something semi-secret to avoid random public requests:

      perl -le'print join "/", "", "reload", (time.$$.rand(9999999)) =~ /(\w\w)/g'
  • repositories

    This should contain a mapping between github repository names and local settings:

    • branch

      The name of the branch on github that you push production code to.

      Tip: Instead of using "master", you might want to use "production" or "release" instead. The reason for this is that it will prevent the server from reloading each time you push to "master":

        # Work
        $ git push origin master
        $ git push origin master
        $ git push origin master
        # Make a new release
        $ git tag 0.31
        $ git push origin release
        # This plugin will cause hypnotoad to hot deploy
    • path

      This is the path on disk to the local git repo.

METHODS

register

  $self->register($app, \%config);

See "SYNOPSIS" for %config parameters.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org