From 5987261f1a5eba83e5bcec740fd8ebdb593ddf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20LU=C3=87I?= Date: Mon, 24 Nov 2014 19:59:55 +0100 Subject: [PATCH] Use the same strategy as on CP by putting a file to detect running instances and if older than 90seconds continue otherwise just let the previous one continue. --- etc/rc.start_packages | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/etc/rc.start_packages b/etc/rc.start_packages index 4ddd908d16..37be6938b2 100755 --- a/etc/rc.start_packages +++ b/etc/rc.start_packages @@ -38,6 +38,18 @@ require_once("pkg-utils.inc"); require_once("pfsense-utils.inc"); require_once("service-utils.inc"); +if (file_exists("{$g['tmp_path']}/.rc.start_packages.running")) { + $stat = stat("{$g['tmp_path']}/.rc.start_packages.running"); + if (time() - $stat['mtime'] >= 90) + @unlink("{$g['tmp_path']}/.rc.start_packages.running"); + else { + log_error("Skipping STARTing packages process because previous/another instance is already running"); + return; + } +} + +@file_put_contents("{$g['tmp_path']}/.rc.start_packages.running", ""); + log_error("Restarting/Starting all packages."); $rcfiles = glob(RCFILEPREFIX . "*.sh"); @@ -71,4 +83,5 @@ if ($shell) { pclose($shell); } +@unlink("{$g['tmp_path']}/.rc.start_packages.running"); ?>