Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 'worker_starting' event. #1755

Closed
wants to merge 7 commits into from

Commits on Apr 6, 2021

  1. Add a 'before_app_start' event.

    This event is always called before the application starts, regardless
    of whether it is invoked via morbo, is started in daemon mode from the
    command line, via hypnotoad in pre-forking mode, as a CGI application
    or as a PSGI.
    
    In pre-forked children, it avoids having to say:
    
        Mojo::IOLoop->next_tick(sub ($ioloop) {
            app->log->info("Worker $$ star...ALL GLORY TO THE HYPNOTOAD!");
        });
    
    to get this special behaviour.  It is way nicer to be able to say:
    
        app->hook(before_app_start => sub ($app) {
            $app->log->info("App in $$ star...ALL GLORY TO MOJOLICIOUS!");
        });
    
    to get that behaviour.
    
    It is more consistent with the over hooks, and also it is a better
    abstraction than having to know the internals of the IOLoop to be
    able to get such a hooking point in pre-forked processes.
    
    Now the application has a unique and consistent entry point where it can
    initialize its global state, regardless of how it is being launched.
    Raphael Manfredi committed Apr 6, 2021
    Configuration menu
    Copy the full SHA
    aadad52 View commit details
    Browse the repository at this point in the history
  2. Ensure we run 'before_app_starting' once per process.

    Raphael Manfredi committed Apr 6, 2021
    Configuration menu
    Copy the full SHA
    07a7601 View commit details
    Browse the repository at this point in the history
  3. Shorter with //=.

    Raphael Manfredi committed Apr 6, 2021
    Configuration menu
    Copy the full SHA
    f0dfb19 View commit details
    Browse the repository at this point in the history
  4. Removing morbo tests, per review.

    Raphael Manfredi committed Apr 6, 2021
    Configuration menu
    Copy the full SHA
    64601b0 View commit details
    Browse the repository at this point in the history
  5. Reformatted paragraphs to 120 chars.

    This is the standard width for that project.
    Raphael Manfredi committed Apr 6, 2021
    Configuration menu
    Copy the full SHA
    53c1470 View commit details
    Browse the repository at this point in the history
  6. Chose between '($app) = @_' and '$app = shift'.

    Raphael Manfredi committed Apr 6, 2021
    Configuration menu
    Copy the full SHA
    2058775 View commit details
    Browse the repository at this point in the history
  7. Prefer 'my $arg = shift;' if just one argument.

    Raphael Manfredi committed Apr 6, 2021
    Configuration menu
    Copy the full SHA
    4700601 View commit details
    Browse the repository at this point in the history