Background dovecot to prevent hang at startup
authorJamie Cameron <jcameron@webmin.com>
Sat, 13 Aug 2011 22:23:00 +0000 (15:23 -0700)
committerJamie Cameron <jcameron@webmin.com>
Sat, 13 Aug 2011 22:23:00 +0000 (15:23 -0700)
dovecot/dovecot-lib.pl

index e04d607..988d19c 100755 (executable)
@@ -308,8 +308,12 @@ sub start_dovecot
 {
 local $script = &get_initscript();
 local $cmd = $script ? "$script start" : $config{'dovecot'};
-local $out = &backquote_logged("$cmd 2>&1 </dev/null");
-return $? ? "<pre>$out</pre>" : undef;
+local $temp = &transname();
+&system_logged("$cmd >$temp 2>&1 </dev/null &");
+sleep(1);
+local $out = &read_file_contents($temp);
+&unlink_file($temp);
+return &is_dovecot_running() ? undef : "<pre>$out</pre>";
 }
 
 # apply_configration()