mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-19 01:51:03 +00:00
Improve config naming consistency and allow per-launch config of quit time
This commit is contained in:
parent
1b447ab2fb
commit
528c6125ef
2 changed files with 58 additions and 26 deletions
|
@ -56,8 +56,9 @@
|
||||||
* ValgrindPath = (string) Run under valgrind (unless empty)
|
* ValgrindPath = (string) Run under valgrind (unless empty)
|
||||||
* ValgrindArgs = (array) Run under valgrind using these args
|
* ValgrindArgs = (array) Run under valgrind using these args
|
||||||
*
|
*
|
||||||
* Ping = (integer) If greater than zero, this is the ping delay in
|
* PingTime = (integer) If greater than zero, this is the ping delay in
|
||||||
* seconds (otherwise the default ofd 240 is used).
|
* seconds (otherwise the default of 240 is used,
|
||||||
|
* or as specified by the CommandPingTime default).
|
||||||
* When a process has been unresponsive to the
|
* When a process has been unresponsive to the
|
||||||
* Command server for this number of seconds, that
|
* Command server for this number of seconds, that
|
||||||
* process is considered to be hung.
|
* process is considered to be hung.
|
||||||
|
@ -70,6 +71,12 @@
|
||||||
* after HungTime in order to gather information
|
* after HungTime in order to gather information
|
||||||
* about the hung process. It's arguments will
|
* about the hung process. It's arguments will
|
||||||
* be the process name and the process ID.
|
* be the process name and the process ID.
|
||||||
|
* QuitTime = (integer) If greater than zero this the interval before
|
||||||
|
* a process is forcably killed if it is stopping
|
||||||
|
* or restarting too slowly. The default (used
|
||||||
|
* if this is not specified and greater than zero)
|
||||||
|
* is 120 seconds (or as specified by the
|
||||||
|
* CommandQuitTime default).
|
||||||
*/
|
*/
|
||||||
Foo = {
|
Foo = {
|
||||||
Prog = "/usr/GNUstep/Local/Tools/Foo"; // Full path to binary
|
Prog = "/usr/GNUstep/Local/Tools/Foo"; // Full path to binary
|
||||||
|
|
73
EcCommand.m
73
EcCommand.m
|
@ -60,7 +60,7 @@ static const NSTimeInterval day = 24.0 * 60.0 * 60.0;
|
||||||
|
|
||||||
static int tStatus = 0;
|
static int tStatus = 0;
|
||||||
|
|
||||||
static NSTimeInterval pingDelay = 240.0;
|
static NSTimeInterval pingTime = 240.0;
|
||||||
|
|
||||||
static int comp_len = 0;
|
static int comp_len = 0;
|
||||||
|
|
||||||
|
@ -113,23 +113,6 @@ static NSTimeInterval quitTime = 120.0;
|
||||||
*/
|
*/
|
||||||
static NSDate *terminateBy = nil;
|
static NSDate *terminateBy = nil;
|
||||||
|
|
||||||
static NSTimeInterval
|
|
||||||
abortDateFromStoppingDate(NSTimeInterval stopping)
|
|
||||||
{
|
|
||||||
NSTimeInterval abortDate = stopping + quitTime;
|
|
||||||
|
|
||||||
if (terminateBy)
|
|
||||||
{
|
|
||||||
NSTimeInterval ti = [terminateBy timeIntervalSinceReferenceDate];
|
|
||||||
|
|
||||||
if (ti < abortDate)
|
|
||||||
{
|
|
||||||
abortDate = ti;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return abortDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NSUInteger launchLimit = 0;
|
static NSUInteger launchLimit = 0;
|
||||||
static BOOL launchEnabled = NO;
|
static BOOL launchEnabled = NO;
|
||||||
static NSMutableDictionary *launchInfo = nil;
|
static NSMutableDictionary *launchInfo = nil;
|
||||||
|
@ -845,6 +828,33 @@ desiredName(Desired state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSTimeInterval) abortDateFromStoppingDate: (NSTimeInterval)stopping
|
||||||
|
{
|
||||||
|
NSTimeInterval when = stopping;
|
||||||
|
NSTimeInterval ti = 0.0;
|
||||||
|
NSString *s;
|
||||||
|
|
||||||
|
s = [[self configuration] objectForKey: @"QuitTime"];
|
||||||
|
if ([s respondsToSelector: @selector(intValue)])
|
||||||
|
{
|
||||||
|
ti = (NSTimeInterval)[s intValue];
|
||||||
|
}
|
||||||
|
if (ti <= 0.0)
|
||||||
|
{
|
||||||
|
ti = quitTime;
|
||||||
|
}
|
||||||
|
when += ti;
|
||||||
|
if (terminateBy)
|
||||||
|
{
|
||||||
|
ti = [terminateBy timeIntervalSinceReferenceDate];
|
||||||
|
if (ti < when)
|
||||||
|
{
|
||||||
|
when = ti;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return when;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) alarm: (EcAlarm*)alarm
|
- (void) alarm: (EcAlarm*)alarm
|
||||||
{
|
{
|
||||||
NSUInteger index;
|
NSUInteger index;
|
||||||
|
@ -2540,7 +2550,7 @@ valgrindLog(NSString *name)
|
||||||
{
|
{
|
||||||
[self resetDelay];
|
[self resetDelay];
|
||||||
stoppingDate = [NSDate timeIntervalSinceReferenceDate];
|
stoppingDate = [NSDate timeIntervalSinceReferenceDate];
|
||||||
abortDate = abortDateFromStoppingDate(stoppingDate);
|
abortDate = [self abortDateFromStoppingDate: stoppingDate];
|
||||||
if ([self hungDate] > 0.0 && identifier > 0)
|
if ([self hungDate] > 0.0 && identifier > 0)
|
||||||
{
|
{
|
||||||
/* The process is hung and we assume it can't shut down gracefully.
|
/* The process is hung and we assume it can't shut down gracefully.
|
||||||
|
@ -2871,7 +2881,7 @@ valgrindLog(NSString *name)
|
||||||
}
|
}
|
||||||
if (abortDate <= 0.0)
|
if (abortDate <= 0.0)
|
||||||
{
|
{
|
||||||
abortDate = abortDateFromStoppingDate(stoppingDate);
|
abortDate = [self abortDateFromStoppingDate: stoppingDate];
|
||||||
}
|
}
|
||||||
if (abortDate <= now)
|
if (abortDate <= now)
|
||||||
{
|
{
|
||||||
|
@ -3501,6 +3511,21 @@ NSLog(@"Problem %@", localException);
|
||||||
|
|
||||||
debug = [[d objectForKey: @"CommandDebug"] boolValue];
|
debug = [[d objectForKey: @"CommandDebug"] boolValue];
|
||||||
|
|
||||||
|
/* The time allowed for a process to respond to pings defaults
|
||||||
|
* to 240 seconds but may be configured in the range from 10 to 600
|
||||||
|
*/
|
||||||
|
ti = [[d objectForKey: @"CommandPingTime"] doubleValue];
|
||||||
|
if (ti == ti && ti > 0.0)
|
||||||
|
{
|
||||||
|
if (ti < 10.0) ti = 10.0;
|
||||||
|
if (ti > 600.0) ti = 600.0;
|
||||||
|
pingTime = ti;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pingTime = 120.0;
|
||||||
|
}
|
||||||
|
|
||||||
/* The time allowed for a process to shut down cleanly defaults
|
/* The time allowed for a process to shut down cleanly defaults
|
||||||
* to 120 seconds but may be configured in the range from 10 to 600
|
* to 120 seconds but may be configured in the range from 10 to 600
|
||||||
*/
|
*/
|
||||||
|
@ -6022,14 +6047,14 @@ NSLog(@"Problem %@", localException);
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s = [[l configuration] objectForKey: @"Ping"];
|
s = [[l configuration] objectForKey: @"PingTime"];
|
||||||
if ([s respondsToSelector: @selector(intValue)])
|
if ([s respondsToSelector: @selector(intValue)])
|
||||||
{
|
{
|
||||||
delay = (NSTimeInterval)[s intValue];
|
delay = (NSTimeInterval)[s intValue];
|
||||||
}
|
}
|
||||||
if (delay <= 0.0)
|
if (delay <= 0.0)
|
||||||
{
|
{
|
||||||
delay = pingDelay; // Default
|
delay = pingTime; // Default
|
||||||
}
|
}
|
||||||
if (d != nil && [d timeIntervalSinceDate: now] < -delay)
|
if (d != nil && [d timeIntervalSinceDate: now] < -delay)
|
||||||
{
|
{
|
||||||
|
@ -6078,13 +6103,13 @@ NSLog(@"Problem %@", localException);
|
||||||
[a removeAllObjects];
|
[a removeAllObjects];
|
||||||
|
|
||||||
if (control != nil && outstanding != nil
|
if (control != nil && outstanding != nil
|
||||||
&& [outstanding timeIntervalSinceDate: now] < -pingDelay)
|
&& [outstanding timeIntervalSinceDate: now] < -pingTime)
|
||||||
{
|
{
|
||||||
NSString *m;
|
NSString *m;
|
||||||
|
|
||||||
m = [NSString stringWithFormat: cmdLogFormat(LT_CONSOLE,
|
m = [NSString stringWithFormat: cmdLogFormat(LT_CONSOLE,
|
||||||
@"Control server failed to respond for over %d seconds"),
|
@"Control server failed to respond for over %d seconds"),
|
||||||
(int)pingDelay];
|
(int)pingTime];
|
||||||
[[(NSDistantObject*)control connectionForProxy] invalidate];
|
[[(NSDistantObject*)control connectionForProxy] invalidate];
|
||||||
[self information: m from: nil to: nil type: LT_CONSOLE];
|
[self information: m from: nil to: nil type: LT_CONSOLE];
|
||||||
lost = YES;
|
lost = YES;
|
||||||
|
|
Loading…
Reference in a new issue