Hi Dan, thanks for the reply. Unfortunately, the END block doesn't work.
But I've solved the problem as follows. The application creates the Selenium::Chrome object via *'has'* as described in the wiki <https://github.com/mojolicious/mojo/wiki/Hypnotoad-prefork-web-server#database-connection-problem-in-preforking> . has Chrome => sub { my $Self = shift; my $Chrome = Selenium::Chrome->new( extra_capabilities => { chromeOptions => { args => [ 'headless', 'no-sandbox', 'window-size=1400,900', 'disk-cache-size=0', 'disable-gpu', 'v8-cache-options=off' ] } }, error_handler => sub { $Self->Log("W", $_[1]); } ); return $Chrome; }; When the server shuts down it sets a flag and stops the Chrome webdriver. $Self->hook(before_server_start => sub { my ($Server, $App) = @_; $Self->{Shutdown} = 0; $Server->ioloop->on(finish => sub { $Self->Log("I", "Shutdown Chrome"); $Self->{Shutdown} = 1; $Self->Chrome->shutdown_binary; }); }); and the controller returns immediately if *$App->{Shutdown}* is 1. Nevertheless, this leads to minor synchronization problems when the server stops Chrome while the application controller is processing a request, but I can handle it. Thanks, Frank Am Freitag, 27. März 2020 16:41:32 UTC+1 schrieb Dan Book: > > You could try shutting it down in an END {} block. To do this you would > need to store the instance to shut down by process ID so you know which one > to shut down. > > -Dan > > On Fri, Mar 27, 2020 at 8:31 AM 'Frank Brendel' via Mojolicious < > mojol...@googlegroups.com <javascript:>> wrote: > >> Hi, >> >> my application needs to load Selenium::Chrome for every single worker >> process. >> I made this via >> Mojo::IOLoop->next_tick(sub { >> $Self->{Chrome} = Selenium::Chrome->new( >> extra_capabilities => { >> chromeOptions => { >> args => [ >> 'headless', 'no-sandbox', 'window-size=1400,900', >> 'disk-cache-size=0', 'disable-gpu', >> 'v8-cache-options=off' >> ] >> } >> }, >> ); >> >> But I have no idea where to shutdown the chrome binary. >> >> I've tried it via the >> Mojo::IOLoop->on(finish >> >> event but that stops the chromedriver to early so that outstanding >> Selenium requests fail. >> >> Thanks >> Frank >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Mojolicious" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to mojol...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/mojolicious/58314c80-14ee-4cbe-8e2f-c7a5bebc7c0a%40googlegroups.com >> >> <https://groups.google.com/d/msgid/mojolicious/58314c80-14ee-4cbe-8e2f-c7a5bebc7c0a%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/a31642d8-ab44-4275-8fc1-be8e10b16473%40googlegroups.com.