Переглянути джерело

return to doing bulk reap renders on post save

George Baugh 5 місяців тому
батько
коміт
c1fe61d8d6
2 змінених файлів з 5 додано та 23 видалено
  1. 5 6
      lib/Trog/Routes/HTML.pm
  2. 0 17
      lib/Trog/Utils.pm

+ 5 - 6
lib/Trog/Routes/HTML.pm

@@ -787,6 +787,7 @@ sub config_save ($query) {
         $query->{message} = "Configuration updated succesfully.";
     }
 
+    #We need to reap the children with outdated configuration.
     $query->{tpsgi}->signal_restart_parent();
 
     return config($query);
@@ -857,14 +858,12 @@ sub post_save ($qq) {
 
     # Instruct tpsgi to invalidate the cached render.
     $qq->{tpsgi}->add_post_close_callback(sub {
-        # We invalidate these in the individual routes themselves.
-        $qq->{tpsgi}->invalidate_render( $qq->{route}, 'html' );
+        # XXX there is not a great way to find what needs to be re-rendered because posts can include other posts.
+        # As such we just have to nuke all the .html renders.
+        $qq->{tpsgi}->invalidate_renders('html');
     });
 
-    # Instruct tpsgi to restart the server after closing the request.
-    $qq->{tpsgi}->signal_restart_parent();
-
-    return $qq->{tpsgi}->see_also($to);
+    return $qq->{tpsgi}->see_also('/secure'.$to);
 }
 
 =head2 profile

+ 0 - 17
lib/Trog/Utils.pm

@@ -29,23 +29,6 @@ sub strip_and_trunc ($s) {
     return substr $s, 0, 280;
 }
 
-# Instruct the parent to restart.  Normally this is HUP, but nginx-unit decides to be special.
-# Don't do anything if running NOHUP=1, which is useful when doing bulk operations
-sub restart_parent ( $parent=undef ) {
-    return if $ENV{NOHUP};
-
-    if ( $ENV{PSGI_ENGINE} && $ENV{PSGI_ENGINE} eq 'nginx-unit' ) {
-        my $conf         = Trog::Config->get();
-        my $nginx_socket = $conf->param('nginx-unit.socket');
-        my $client       = HTTP::Tiny::UNIX->new();
-        my $res          = $client->request( 'GET', "http:$nginx_socket//control/applications/tcms/restart" );
-        WARN("could not reload application (got $res->{status} from nginx-unit)!") unless $res->{status} == 200;
-        return 1;
-    }
-    $parent //= getppid;
-    kill 'HUP', $parent;
-}
-
 sub uuid {
     return UUID::uuid();
 }