mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-19 10:01:24 +00:00
More launch control options
This commit is contained in:
parent
958bb2a4c4
commit
29d4f167c6
3 changed files with 89 additions and 13 deletions
|
@ -7,6 +7,10 @@
|
||||||
of launching tasks is reached, new tasks should be launched as and
|
of launching tasks is reached, new tasks should be launched as and
|
||||||
when launching tasks complete their startup and register with the
|
when launching tasks complete their startup and register with the
|
||||||
Command server.
|
Command server.
|
||||||
|
Add suspend and resume command to control whether the Command server
|
||||||
|
will actually launch/relaunch tasks, along with a LaunchStartSuspended
|
||||||
|
user default to control whether launching starts as soon as the Command
|
||||||
|
server starts up (by default launching is not suspended on startup).
|
||||||
|
|
||||||
2018-12-11 Richard Frith-Macdonald <rfm@gnu.org>
|
2018-12-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -72,11 +72,6 @@
|
||||||
Time = 30; // Interval for relaunching after crash
|
Time = 30; // Interval for relaunching after crash
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/* Specify how many tasks the Command server may have launching
|
|
||||||
* concurrently (default is 20). You may want to set this to a
|
|
||||||
* lower value in order to reduce load when the system start up.
|
|
||||||
*/
|
|
||||||
LaunchLimit = 20;
|
|
||||||
/* Specify launch order ... Feep first, Bar second
|
/* Specify launch order ... Feep first, Bar second
|
||||||
* Processes not listed here are launched in lexicographical order
|
* Processes not listed here are launched in lexicographical order
|
||||||
* after any processes which are listed.
|
* after any processes which are listed.
|
||||||
|
@ -85,6 +80,17 @@
|
||||||
Feep, // Launch Feep first
|
Feep, // Launch Feep first
|
||||||
Bar // Launch Bar second
|
Bar // Launch Bar second
|
||||||
);
|
);
|
||||||
|
/* Specify how many tasks the Command server may have launching
|
||||||
|
* concurrently (default is 20). You may want to set this to a
|
||||||
|
* lower value in order to reduce load when the system start up.
|
||||||
|
*/
|
||||||
|
LaunchLimit = 20;
|
||||||
|
/* Specify whether, when the Command server starts, launching of
|
||||||
|
* tasks should be suspeneded (as if the 'suspend' command had been
|
||||||
|
* sent to it from the Console).
|
||||||
|
* By default this is NO.
|
||||||
|
*/
|
||||||
|
LaunchStartSuspended = NO;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/* Section specific for the Control server itself.
|
/* Section specific for the Control server itself.
|
||||||
|
|
82
EcCommand.m
82
EcCommand.m
|
@ -126,6 +126,7 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
NSString *logname;
|
NSString *logname;
|
||||||
NSMutableDictionary *config;
|
NSMutableDictionary *config;
|
||||||
NSUInteger launchLimit;
|
NSUInteger launchLimit;
|
||||||
|
BOOL launchSuspended;
|
||||||
NSDictionary *launchInfo;
|
NSDictionary *launchInfo;
|
||||||
NSArray *launchOrder;
|
NSArray *launchOrder;
|
||||||
NSDictionary *environment;
|
NSDictionary *environment;
|
||||||
|
@ -233,6 +234,13 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) ecAwaken
|
||||||
|
{
|
||||||
|
[super ecAwaken];
|
||||||
|
launchSuspended = [[self cmdDefaults] boolForKey: @"LaunchStartSuspended"];
|
||||||
|
[self _timedOut: nil]; // Simulate timeout to set timer going
|
||||||
|
}
|
||||||
|
|
||||||
- (oneway void) unmanage: (in bycopy NSString*)managedObject
|
- (oneway void) unmanage: (in bycopy NSString*)managedObject
|
||||||
{
|
{
|
||||||
NS_DURING
|
NS_DURING
|
||||||
|
@ -826,7 +834,7 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
{
|
{
|
||||||
m = @"Commands are -\n"
|
m = @"Commands are -\n"
|
||||||
@"Help\tArchive\tControl\tLaunch\tList\tMemory\t"
|
@"Help\tArchive\tControl\tLaunch\tList\tMemory\t"
|
||||||
@"Quit\tRestart\tTell\n\n"
|
@"Quit\tRestart\tResume\tSuspend\tTell\n\n"
|
||||||
@"Type 'help' followed by a command word for details.\n"
|
@"Type 'help' followed by a command word for details.\n"
|
||||||
@"A command line consists of a sequence of words, "
|
@"A command line consists of a sequence of words, "
|
||||||
@"the first of which is the command to be executed. "
|
@"the first of which is the command to be executed. "
|
||||||
|
@ -900,6 +908,16 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
@"Restart self\n"
|
@"Restart self\n"
|
||||||
@"Shuts down and starts Command server for this host.\n";
|
@"Shuts down and starts Command server for this host.\n";
|
||||||
}
|
}
|
||||||
|
else if (comp(wd, @"Resume") >= 0)
|
||||||
|
{
|
||||||
|
m = @"Resumes the launching/relaunching of tasks.\n"
|
||||||
|
@"Has no effect if launching has not been suspended.\n";
|
||||||
|
}
|
||||||
|
else if (comp(wd, @"Suspend") >= 0)
|
||||||
|
{
|
||||||
|
m = @"Suspends the launching/relaunching of tasks.\n"
|
||||||
|
@"Has no effect if this has already been suspended.\n";
|
||||||
|
}
|
||||||
else if (comp(wd, @"Tell") >= 0)
|
else if (comp(wd, @"Tell") >= 0)
|
||||||
{
|
{
|
||||||
m = @"Tell 'name' 'command'\n"
|
m = @"Tell 'name' 'command'\n"
|
||||||
|
@ -910,17 +928,29 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
}
|
}
|
||||||
else if (comp(wd, @"launch") >= 0)
|
else if (comp(wd, @"launch") >= 0)
|
||||||
{
|
{
|
||||||
if ([cmd count] > 1)
|
if (YES == launchSuspended)
|
||||||
|
{
|
||||||
|
m = @"Launching of tasks is suspended.\n"
|
||||||
|
@"Use the Resume command to resume launching.\n";
|
||||||
|
}
|
||||||
|
else if ([cmd count] > 1)
|
||||||
{
|
{
|
||||||
|
NSString *nam = [cmd objectAtIndex: 1];
|
||||||
|
BOOL all = NO;
|
||||||
|
|
||||||
|
if ([nam caseInsensitiveCompare: @"all"] == NSOrderedSame)
|
||||||
|
{
|
||||||
|
all = YES;
|
||||||
|
}
|
||||||
|
|
||||||
if (launchInfo != nil)
|
if (launchInfo != nil)
|
||||||
{
|
{
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
NSString *key;
|
NSString *key;
|
||||||
NSString *nam = [cmd objectAtIndex: 1];
|
|
||||||
BOOL found = NO;
|
BOOL found = NO;
|
||||||
|
|
||||||
enumerator = [launchOrder objectEnumerator];
|
enumerator = [launchOrder objectEnumerator];
|
||||||
if ([nam caseInsensitiveCompare: @"all"] == NSOrderedSame)
|
if (YES == all)
|
||||||
{
|
{
|
||||||
NSMutableArray *names = [NSMutableArray array];
|
NSMutableArray *names = [NSMutableArray array];
|
||||||
|
|
||||||
|
@ -1103,6 +1133,12 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
{
|
{
|
||||||
m = @"There are no programs we can launch.\n";
|
m = @"There are no programs we can launch.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (YES == launchSuspended)
|
||||||
|
{
|
||||||
|
m = [m stringByAppendingString:
|
||||||
|
@"\nLaunching is suspended.\n"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (comp(wd, @"memory") >= 0)
|
else if (comp(wd, @"memory") >= 0)
|
||||||
|
@ -1327,6 +1363,31 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
m = @"Restart what?.\n";
|
m = @"Restart what?.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (comp(wd, @"resume") >= 0)
|
||||||
|
{
|
||||||
|
if (YES == launchSuspended)
|
||||||
|
{
|
||||||
|
launchSuspended = NO;
|
||||||
|
m = @"Launching is now resumed.\n";
|
||||||
|
[self timeoutSoon];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m = @"Launching was/is not suspended.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (comp(wd, @"suspend") >= 0)
|
||||||
|
{
|
||||||
|
if (YES == launchSuspended)
|
||||||
|
{
|
||||||
|
m = @"Launching was/is already suspended.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
launchSuspended = YES;
|
||||||
|
m = @"Launching is now suspended.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (comp(wd, @"tell") >= 0)
|
else if (comp(wd, @"tell") >= 0)
|
||||||
{
|
{
|
||||||
wd = cmdWord(cmd, 1);
|
wd = cmdWord(cmd, 1);
|
||||||
|
@ -1820,8 +1881,6 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
clients = [[NSMutableArray alloc] initWithCapacity: 10];
|
clients = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||||
launches = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
launches = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
||||||
launching = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
launching = [[NSMutableDictionary alloc] initWithCapacity: 10];
|
||||||
|
|
||||||
[self _timedOut: nil]; // Simulate timeout to set timer going
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -2029,9 +2088,16 @@ static NSString* cmdWord(NSArray* a, unsigned int pos)
|
||||||
- (void) launch
|
- (void) launch
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *arp;
|
NSAutoreleasePool *arp;
|
||||||
NSMutableArray *toTry = AUTORELEASE([launchOrder mutableCopy]);
|
NSMutableArray *toTry;
|
||||||
NSDate *now = [NSDate date];
|
NSDate *now;
|
||||||
|
|
||||||
|
if (launchSuspended)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toTry = AUTORELEASE([launchOrder mutableCopy]);
|
||||||
|
now = [NSDate date];
|
||||||
arp = [NSAutoreleasePool new];
|
arp = [NSAutoreleasePool new];
|
||||||
|
|
||||||
while ([toTry count] > 0)
|
while ([toTry count] > 0)
|
||||||
|
|
Loading…
Reference in a new issue