From d89332f25e512de5e80659cab183786f805c7db6 Mon Sep 17 00:00:00 2001
From: pandora-release <noreply@pandorafms.org>
Date: Wed, 18 Jun 2014 09:57:17 +0000
Subject: [PATCH] Fixes to the Windows service.

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10230 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/bin/pandora_server      | 2 +-
 pandora_server/lib/PandoraFMS/Tools.pm | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server
index ee63b73f8c..316e9ca69c 100755
--- a/pandora_server/bin/pandora_server
+++ b/pandora_server/bin/pandora_server
@@ -350,7 +350,7 @@ sub win32_install_service() {
 
 	# Configure and install the service.
 	my $service_path = $0;
-	my $service_params = "-S run \"$ARGV[0]\"";
+	my $service_params = "-S run \"" . $Config{'pandora_path'} ."\"";
 	my %service_hash = (
 		machine =>  '',
 		name	=>  'PANDORAFMSSRV',
diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm
index 2c74e272c3..1ddadf6702 100644
--- a/pandora_server/lib/PandoraFMS/Tools.pm
+++ b/pandora_server/lib/PandoraFMS/Tools.pm
@@ -494,8 +494,12 @@ sub enterprise_load ($) {
 	#return 1 if (is_loaded ('PandoraFMS::Enterprise'));
 	
 	# Try to load the module
-	# eval 'local $SIG{__DIE__}; require PandoraFMS::Enterprise;';
-	eval 'require PandoraFMS::Enterprise;';
+	if ($^O eq 'MSWin32') {
+		# If the Windows service dies the service is stopped, even inside an eval ($RUN is set to 0)!
+		eval 'local $SIG{__DIE__}; require PandoraFMS::Enterprise;';
+	} else {
+		eval 'require PandoraFMS::Enterprise;';
+	}
 	
 	# Ops
 	return 0 if ($@);