Author: rfm
Date: Thu Oct 23 11:46:04 2014
New Revision: 38129
URL: http://svn.gna.org/viewcvs/gnustep?rev=38129&view=rev
Log:
allow control of launch order
Modified:
libs/ec/trunk/ChangeLog
libs/ec/trunk/Control.plist
libs/ec/trunk/EcCommand.m
Modified: libs/ec/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=38129&r1=38128&r2=38129&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog (original)
+++ libs/ec/trunk/ChangeLog Thu Oct 23 11:46:04 2014
@@ -1,3 +1,11 @@
+2014-10-23 Richard Frith-Macdonald <[email protected]>
+
+ * EcCommand.m:
+ * Control.plist:
+ Add LaunchOrder config to control the order in which services are
+ handled by the Command server. By default we now do them in
+ lexicographic order rather than leaving the order undefined.
+
2014-09-16 Richard Frith-Macdonald <[email protected]>
* EcCommand.m: Simplify handling of loss of process and configuration
Modified: libs/ec/trunk/Control.plist
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/Control.plist?rev=38129&r1=38128&r2=38129&view=diff
==============================================================================
--- libs/ec/trunk/Control.plist (original)
+++ libs/ec/trunk/Control.plist Thu Oct 23 11:46:04 2014
@@ -6,6 +6,10 @@
*/
* = {
/* Common section for all processes on any/all hosts.
+ */
+ };
+ Feep = {
+ /* Section for the process Feep on any/all hosts.
*/
};
Foo = {
@@ -20,6 +24,10 @@
/* Common section for any/all processses on localhost.
*/
};
+ Bar = {
+ /* Section for process Bar on localhost
+ */
+ };
Foo = {
/* Section for process Foo on localhost
*/
@@ -29,12 +37,31 @@
*/
Launch = {
Foo = {
- Prog = "/usr/GNUstep/Local/Tools/Foo"; // Path to binary
+ Prog = "/usr/GNUstep/Local/Tools/Foo"; // Full path to binary
Home = "~xxx/Test"; // Directory to run in
Args = ("-Debug", "YES"); // Args to launch with
Auto = NO; // Auto-launch?
};
+ Bar = {
+ Prog = "Bar"; // RName of binary
+ Home = "~xxx/Test"; // Directory to run in
+ Args = ("-Debug", "YES"); // Args to launch with
+ Auto = YES; // Auto-launch?
+ };
+ Feep = {
+ Prog = "Feep"; // RName of binary
+ Home = "~xxx/Test"; // Directory to run in
+ Auto = YES; // Auto-launch?
+ };
};
+ /* Specify launch order ... Feep first, Bar second
+ * Processes not listed here are launched in lexicographical order
+ * after any processes which are listed.
+ */
+ LaunchOrder = (
+ Feep, // Launch Feep first
+ Bar // Launch Bar second
+ );
};
};
}
Modified: libs/ec/trunk/EcCommand.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcCommand.m?rev=38129&r1=38128&r2=38129&view=diff
==============================================================================
--- libs/ec/trunk/EcCommand.m (original)
+++ libs/ec/trunk/EcCommand.m Thu Oct 23 11:46:04 2014
@@ -126,6 +126,7 @@
NSString *logname;
NSMutableDictionary *config;
NSDictionary *launchInfo;
+ NSArray *launchOrder;
NSDictionary *environment;
NSMutableDictionary *launches;
NSMutableSet *launching;
@@ -306,9 +307,11 @@
d = [config objectForKey: [self cmdName]];
DESTROY(launchInfo);
+ DESTROY(launchOrder);
DESTROY(environment);
if ([d isKindOfClass: [NSDictionary class]] == YES)
{
+ id o;
NSMutableDictionary *m;
NSString *k;
NSString *err = nil;
@@ -446,6 +449,67 @@
}
}
RETAIN(launchInfo);
+
+ o = [d objectForKey: @"LaunchOrder"];
+ if (NO == [o isKindOfClass: [NSArray class]])
+ {
+ if (nil != o)
+ {
+ NSLog(@"bad 'LaunchOrder' config (not an array) ignored");
+ }
+ /* The default launch order is alphabetical by server name.
+ */
+ o = [[launchInfo allKeys] sortedArrayUsingSelector:
+ @selector(compare:)];
+ launchOrder = RETAIN(o);
+ }
+ else
+ {
+ NSMutableArray *m;
+ NSEnumerator *e;
+ NSString *k;
+ NSUInteger c;
+
+ m = AUTORELEASE([o mutableCopy]);
+ c = [m count];
+ while (c-- > 0)
+ {
+ o = [m objectAtIndex: c];
+ if (NO == [o isKindOfClass: [NSString class]])
+ {
+ NSLog(@"bad 'LaunchOrder' item ('%@' at %u) ignored"
+ @" (not a server name)", o, (unsigned)c);
+ [m removeObjectAtIndex: c];
+ }
+ else if ([m indexOfObject: o] != c)
+ {
+ NSLog(@"bad 'LaunchOrder' item ('%@' at %u) ignored"
+ @" (repeat of earlier item)", o, (unsigned)c);
+ [m removeObjectAtIndex: c];
+ }
+ else if (nil == [launchInfo objectForKey: o])
+ {
+ NSLog(@"bad 'LaunchOrder' item ('%@' at %u) ignored"
+ @" (not in 'Launch' dictionary)", o, (unsigned)c);
+ [m removeObjectAtIndex: c];
+ }
+ }
+ /* Any missing servers are launched after others
+ * they are in lexicographic order.
+ */
+ o = [[launchInfo allKeys] sortedArrayUsingSelector:
+ @selector(compare:)];
+ e = [o objectEnumerator];
+ while (nil != (k = [e nextObject]))
+ {
+ if (NO == [m containsObject: k])
+ {
+ [m addObject: k];
+ }
+ }
+ launchOrder = [m copy];
+ }
+
environment = [d objectForKey: @"Environment"];
if ([environment isKindOfClass: [NSDictionary class]] == NO)
{
@@ -774,7 +838,7 @@
NSString *nam = [cmd objectAtIndex: 1];
BOOL found = NO;
- enumerator = [launchInfo keyEnumerator];
+ enumerator = [launchOrder objectEnumerator];
if ([nam caseInsensitiveCompare: @"all"] == NSOrderedSame)
{
NSMutableArray *names = [NSMutableArray array];
@@ -1058,7 +1122,7 @@
NSEnumerator *enumerator;
NSString *key;
- enumerator = [launchInfo keyEnumerator];
+ enumerator = [launchOrder objectEnumerator];
while ((key = [enumerator nextObject]) != nil)
{
if (comp(wd, key) >= 0)
@@ -1424,6 +1488,7 @@
RELEASE(host);
RELEASE(clients);
RELEASE(launchInfo);
+ RELEASE(launchOrder);
RELEASE(environment);
RELEASE(lastUnanswered);
[super dealloc];
@@ -1625,7 +1690,7 @@
NSDate *firstDate = nil;
NSDate *now = [NSDate date];
- enumerator = [launchInfo keyEnumerator];
+ enumerator = [launchOrder objectEnumerator];
while ((key = [enumerator nextObject]) != nil)
{
EcClientI *r = [self findIn: clients byName: key];
@@ -1880,7 +1945,7 @@
NSEnumerator *enumerator;
NSString *key;
- enumerator = [launchInfo keyEnumerator];
+ enumerator = [launchOrder objectEnumerator];
while ((key = [enumerator nextObject]) != nil)
{
[launches setObject: [NSDate distantFuture] forKey: key];
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs