restart stopped instances on update
authorFelix Fietkau <nbd@openwrt.org>
Fri, 31 May 2013 15:14:50 +0000 (17:14 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 31 May 2013 15:27:40 +0000 (17:27 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
instance.c

index 1c2d8ba74e8a2570c9b2bdd8f8f2a451a7f16efc..a1459b74dcadc62299a62250bb0d0644241510bb 100644 (file)
@@ -322,13 +322,20 @@ bool
 instance_update(struct service_instance *in, struct service_instance *in_new)
 {
        bool changed = instance_config_changed(in, in_new);
+       bool running = in->proc.pending;
 
-       if (!changed)
+       if (!changed && running)
                return false;
 
-       in->restart = true;
-       instance_stop(in, true);
-       instance_config_move(in, in_new);
+       if (!running) {
+               if (changed)
+                       instance_config_move(in, in_new);
+               instance_start(in);
+       } else {
+               in->restart = true;
+               instance_stop(in, true);
+               instance_config_move(in, in_new);
+       }
        return true;
 }