mirror of
				https://github.com/Icinga/icinga2.git
				synced 2025-10-31 03:03:52 +01:00 
			
		
		
		
	
							parent
							
								
									c385355c38
								
							
						
					
					
						commit
						31e5394fe9
					
				| @ -305,7 +305,8 @@ void Application::RunEventLoop() | |||||||
| 				m_ReloadProcess = StartReloadProcess(); | 				m_ReloadProcess = StartReloadProcess(); | ||||||
| 			} | 			} | ||||||
| #else /* _WIN32 */ | #else /* _WIN32 */ | ||||||
| 			Log(LogNotice, "Application") << "Got reload command, forwarding to umbrella process (PID " << m_UmbrellaProcess << ")"; | 			Log(LogNotice, "Application") | ||||||
|  | 				<< "Got reload command, forwarding to umbrella process (PID " << m_UmbrellaProcess << ")"; | ||||||
| 
 | 
 | ||||||
| 			(void)kill(m_UmbrellaProcess, SIGHUP); | 			(void)kill(m_UmbrellaProcess, SIGHUP); | ||||||
| #endif /* _WIN32 */ | #endif /* _WIN32 */ | ||||||
|  | |||||||
| @ -208,17 +208,20 @@ int RunWorker(const std::vector<std::string>& configs) | |||||||
| 			return EXIT_FAILURE; | 			return EXIT_FAILURE; | ||||||
| 
 | 
 | ||||||
| #ifndef _WIN32 | #ifndef _WIN32 | ||||||
| 		Log(LogNotice, "cli") << "Notifying umbrella process (PID " << l_UmbrellaPid << ") about the config loading success"; | 		Log(LogNotice, "cli") | ||||||
|  | 			<< "Notifying umbrella process (PID " << l_UmbrellaPid << ") about the config loading success"; | ||||||
| 
 | 
 | ||||||
| 		(void)kill(l_UmbrellaPid, SIGUSR2); | 		(void)kill(l_UmbrellaPid, SIGUSR2); | ||||||
| 
 | 
 | ||||||
| 		Log(LogNotice, "cli") << "Waiting for the umbrella process to let us doing the actual work"; | 		Log(LogNotice, "cli") | ||||||
|  | 			<< "Waiting for the umbrella process to let us doing the actual work"; | ||||||
| 
 | 
 | ||||||
| 		while (!l_AllowedToWork.load()) { | 		while (!l_AllowedToWork.load()) { | ||||||
| 			Utility::Sleep(0.2); | 			Utility::Sleep(0.2); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		Log(LogNotice, "cli") << "The umbrella process let us continuing"; | 		Log(LogNotice, "cli") | ||||||
|  | 			<< "The umbrella process let us continuing"; | ||||||
| #endif /* _WIN32 */ | #endif /* _WIN32 */ | ||||||
| 
 | 
 | ||||||
| 		/* restore the previous program state */ | 		/* restore the previous program state */ | ||||||
| @ -399,7 +402,8 @@ static void NotifyWatchdog() | |||||||
|  */ |  */ | ||||||
| static pid_t StartUnixWorker(const std::vector<std::string>& configs) | static pid_t StartUnixWorker(const std::vector<std::string>& configs) | ||||||
| { | { | ||||||
| 	Log(LogNotice, "cli") << "Spawning seemless worker process doing the actual work"; | 	Log(LogNotice, "cli") | ||||||
|  | 		<< "Spawning seemless worker process doing the actual work"; | ||||||
| 
 | 
 | ||||||
| 	try { | 	try { | ||||||
| 		Application::UninitializeBase(); | 		Application::UninitializeBase(); | ||||||
| @ -466,7 +470,8 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs) | |||||||
| 			l_CurrentlyStartingUnixWorkerPid.store(pid); | 			l_CurrentlyStartingUnixWorkerPid.store(pid); | ||||||
| 			(void)sigprocmask(SIG_UNBLOCK, &l_UnixWorkerSignals, nullptr); | 			(void)sigprocmask(SIG_UNBLOCK, &l_UnixWorkerSignals, nullptr); | ||||||
| 
 | 
 | ||||||
| 			Log(LogNotice, "cli") << "Spawned worker process (PID " << pid << "), waiting for it to load its config"; | 			Log(LogNotice, "cli") | ||||||
|  | 				<< "Spawned worker process (PID " << pid << "), waiting for it to load its config"; | ||||||
| 
 | 
 | ||||||
| 			// Wait for the newly spawned process to either load its config or fail.
 | 			// Wait for the newly spawned process to either load its config or fail.
 | ||||||
| 			for (;;) { | 			for (;;) { | ||||||
| @ -476,10 +481,12 @@ static pid_t StartUnixWorker(const std::vector<std::string>& configs) | |||||||
| 
 | 
 | ||||||
| 				switch (l_CurrentlyStartingUnixWorkerState.load()) { | 				switch (l_CurrentlyStartingUnixWorkerState.load()) { | ||||||
| 					case UnixWorkerState::LoadedConfig: | 					case UnixWorkerState::LoadedConfig: | ||||||
| 						Log(LogNotice, "cli") << "Worker process successfully loaded its config"; | 						Log(LogNotice, "cli") | ||||||
|  | 							<< "Worker process successfully loaded its config"; | ||||||
| 						break; | 						break; | ||||||
| 					case UnixWorkerState::Failed: | 					case UnixWorkerState::Failed: | ||||||
| 						Log(LogNotice, "cli") << "Worker process couldn't load its config"; | 						Log(LogNotice, "cli") | ||||||
|  | 							<< "Worker process couldn't load its config"; | ||||||
| 
 | 
 | ||||||
| 						while (waitpid(pid, nullptr, 0) == -1 && errno == EINTR) { | 						while (waitpid(pid, nullptr, 0) == -1 && errno == EINTR) { | ||||||
| #ifdef HAVE_SYSTEMD | #ifdef HAVE_SYSTEMD | ||||||
| @ -659,7 +666,8 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin | |||||||
| 		if (!requestedTermination) { | 		if (!requestedTermination) { | ||||||
| 			int termSig = l_TermSignal.load(); | 			int termSig = l_TermSignal.load(); | ||||||
| 			if (termSig != -1) { | 			if (termSig != -1) { | ||||||
| 				Log(LogNotice, "cli") << "Got signal " << termSig << ", forwarding to seemless worker (PID " << currentWorker << ")"; | 				Log(LogNotice, "cli") | ||||||
|  | 					<< "Got signal " << termSig << ", forwarding to seemless worker (PID " << currentWorker << ")"; | ||||||
| 
 | 
 | ||||||
| 				(void)kill(currentWorker, termSig); | 				(void)kill(currentWorker, termSig); | ||||||
| 				requestedTermination = true; | 				requestedTermination = true; | ||||||
| @ -674,7 +682,8 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (l_RequestedReload.exchange(false)) { | 		if (l_RequestedReload.exchange(false)) { | ||||||
| 			Log(LogInformation, "Application") << "Got reload command: Starting new instance."; | 			Log(LogInformation, "Application") | ||||||
|  | 				<< "Got reload command: Starting new instance."; | ||||||
| 
 | 
 | ||||||
| #ifdef HAVE_SYSTEMD | #ifdef HAVE_SYSTEMD | ||||||
| 			sd_notify(0, "RELOADING=1"); | 			sd_notify(0, "RELOADING=1"); | ||||||
| @ -685,7 +694,8 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin | |||||||
| 			if (nextWorker == -1) { | 			if (nextWorker == -1) { | ||||||
| 				Log(LogCritical, "Application", "Found error in config: reloading aborted"); | 				Log(LogCritical, "Application", "Found error in config: reloading aborted"); | ||||||
| 			} else { | 			} else { | ||||||
| 				Log(LogInformation, "Application") << "Reload done, old process shutting down. Child process with PID '" << nextWorker << "' is taking over."; | 				Log(LogInformation, "Application") | ||||||
|  | 					<< "Reload done, old process shutting down. Child process with PID '" << nextWorker << "' is taking over."; | ||||||
| 
 | 
 | ||||||
| 				(void)kill(currentWorker, SIGTERM); | 				(void)kill(currentWorker, SIGTERM); | ||||||
| 
 | 
 | ||||||
| @ -698,7 +708,8 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin | |||||||
| #endif /* HAVE_SYSTEMD */ | #endif /* HAVE_SYSTEMD */ | ||||||
| 					} | 					} | ||||||
| 
 | 
 | ||||||
| 					Log(LogNotice, "cli") << "Waited for " << Utility::FormatDuration(Utility::GetTime() - start) << " on old process to exit."; | 					Log(LogNotice, "cli") | ||||||
|  | 						<< "Waited for " << Utility::FormatDuration(Utility::GetTime() - start) << " on old process to exit."; | ||||||
| 				} | 				} | ||||||
| 
 | 
 | ||||||
| 				// Old instance shut down, allow the new one to continue working beyond config validation
 | 				// Old instance shut down, allow the new one to continue working beyond config validation
 | ||||||
| @ -714,7 +725,8 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (l_RequestedReopenLogs.exchange(false)) { | 		if (l_RequestedReopenLogs.exchange(false)) { | ||||||
| 			Log(LogNotice, "cli") << "Got signal " << SIGUSR1 << ", forwarding to seemless worker (PID " << currentWorker << ")"; | 			Log(LogNotice, "cli") | ||||||
|  | 				<< "Got signal " << SIGUSR1 << ", forwarding to seemless worker (PID " << currentWorker << ")"; | ||||||
| 
 | 
 | ||||||
| 			(void)kill(currentWorker, SIGUSR1); | 			(void)kill(currentWorker, SIGUSR1); | ||||||
| 		} | 		} | ||||||
| @ -722,7 +734,8 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin | |||||||
| 		{ | 		{ | ||||||
| 			int status; | 			int status; | ||||||
| 			if (waitpid(currentWorker, &status, WNOHANG) > 0) { | 			if (waitpid(currentWorker, &status, WNOHANG) > 0) { | ||||||
| 				Log(LogNotice, "cli") << "Seemless worker (PID " << currentWorker << ") stopped, stopping as well"; | 				Log(LogNotice, "cli") | ||||||
|  | 					<< "Seemless worker (PID " << currentWorker << ") stopped, stopping as well"; | ||||||
| 
 | 
 | ||||||
| #ifdef HAVE_SYSTEMD | #ifdef HAVE_SYSTEMD | ||||||
| 				if (!notifiedTermination) { | 				if (!notifiedTermination) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user