Monotone-Parent: ab93644a5ada4e53c8539d710eff6a21c9d7fdc4
Monotone-Revision: 1f071b472ff826a3cdfb0f8ecafbe3f2c31e969e Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-12-22T16:58:26 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
bc2094427f
commit
bf68910d9b
|
@ -4579,7 +4579,7 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
#if defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||
|
||||
int WOWatchDogApplicationMain
|
||||
@@ -39,201 +60,900 @@
|
||||
@@ -39,201 +60,911 @@
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -5309,24 +5309,35 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
+- (NGInternetSocketAddress *) _listeningAddress
|
||||
+{
|
||||
+ NGInternetSocketAddress *listeningAddress;
|
||||
+ NSUserDefaults *ud;
|
||||
+ id port, allow;
|
||||
+
|
||||
+ listeningAddress = nil;
|
||||
+
|
||||
+ port = [NSClassFromString (appName) port];
|
||||
+ ud = [NSUserDefaults standardUserDefaults];
|
||||
+ port = [ud objectForKey:@"p"];
|
||||
+ if (!port) {
|
||||
+ port = [ud objectForKey:@"WOPort"];
|
||||
+ if (!port)
|
||||
+ port = @"auto";
|
||||
+ allow
|
||||
+ = [[NSUserDefaults standardUserDefaults] objectForKey:@"WOHttpAllowHost"];
|
||||
}
|
||||
- signal(_signal, signalHandler);
|
||||
+ allow = [ud objectForKey:@"WOHttpAllowHost"];
|
||||
+ if (allow)
|
||||
+ [self warnWithFormat: @"'WOHttpAllowHost' is ignored in watchdog mode, use a real firewall instead"];
|
||||
+ if ([port isKindOfClass: [NSString class]]) {
|
||||
+ if ([port isEqualToString: @"auto"]) {
|
||||
+ listeningAddress
|
||||
+ = [[NGInternetSocketAddress alloc] initWithPort:0 onHost:@"127.0.0.1"];
|
||||
+ [listeningAddress autorelease];
|
||||
+ } else if ([port rangeOfString: @":"].location == NSNotFound && !allow)
|
||||
+ port = [NSString stringWithFormat: @"127.0.0.1:%@", port];
|
||||
}
|
||||
- signal(_signal, signalHandler);
|
||||
+ } else if ([port rangeOfString: @":"].location == NSNotFound) {
|
||||
+ if (allow)
|
||||
+ listeningAddress =
|
||||
+ [NGInternetSocketAddress wildcardAddressWithPort:[port intValue]];
|
||||
+ else
|
||||
+ port = [NSString stringWithFormat: @"127.0.0.1:%d", [port intValue]];
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ if (allow)
|
||||
+ listeningAddress =
|
||||
|
@ -5641,11 +5652,16 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
#if LIB_FOUNDATION_LIBRARY || defined(GS_PASS_ARGUMENTS)
|
||||
{
|
||||
extern char **environ;
|
||||
@@ -241,179 +961,68 @@
|
||||
@@ -241,179 +972,68 @@
|
||||
environment:(void*)environ];
|
||||
}
|
||||
#endif
|
||||
-
|
||||
+
|
||||
+ /* This invocation forces the class initialization of WOCoreApplication,
|
||||
+ which causes the NSUserDefaults to be initialized as well with
|
||||
+ Defaults.plist. */
|
||||
+ [NSClassFromString (appName) class];
|
||||
+
|
||||
ud = [NSUserDefaults standardUserDefaults];
|
||||
-
|
||||
|
@ -5711,8 +5727,34 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
- else {
|
||||
- sleep(1);
|
||||
- }
|
||||
- }
|
||||
- else {
|
||||
+ if (stdout && stderr) {
|
||||
+ if ([ud boolForKey: @"WONoDetach"])
|
||||
+ childPid = 0;
|
||||
+ else
|
||||
+ childPid = fork();
|
||||
+
|
||||
+ if (childPid) {
|
||||
+ rc = 0;
|
||||
+ }
|
||||
+ else {
|
||||
+ nsPidFile = [ud objectForKey: @"WOPidFile"];
|
||||
+ if (!nsPidFile)
|
||||
+ nsPidFile = [NSString stringWithFormat: @"/var/run/%@/%@.pid",
|
||||
+ [processInfo processName],
|
||||
+ [processInfo processName]];
|
||||
+ pidFile = [nsPidFile UTF8String];
|
||||
+ if (_writePid(nsPidFile)) {
|
||||
+ respawnDelay = [ud integerForKey: @"WORespawnDelay"];
|
||||
+ if (!respawnDelay)
|
||||
+ respawnDelay = 5;
|
||||
+ /* default is to use the watch dog! */
|
||||
+ if ([ud objectForKey:@"WOUseWatchDog"] != nil
|
||||
+ && ![ud boolForKey:@"WOUseWatchDog"])
|
||||
+ rc = WOApplicationMain(appName, argc, argv);
|
||||
+ else
|
||||
+ rc = [[WOWatchDog sharedWatchDog] run: appName argc: argc argv: argv];
|
||||
}
|
||||
else {
|
||||
- if (child == 0) {
|
||||
- /* child process */
|
||||
- signal(SIGPIPE, SIG_DFL);
|
||||
|
@ -5723,12 +5765,7 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
-
|
||||
- if (isVerbose)
|
||||
- fprintf(stderr, "starting child %i ..\n", getpid());
|
||||
+ if (stdout && stderr) {
|
||||
+ /* This invocation forces the class initialization of WOCoreApplication,
|
||||
+ which causes the NSUserDefaults to be initialized as well with
|
||||
+ Defaults.plist. */
|
||||
+ [NSClassFromString (appName) port];
|
||||
|
||||
-
|
||||
- pidFile = [pidFile stringByAppendingPathExtension:@"child"];
|
||||
- _writePid(pidFile);
|
||||
-
|
||||
|
@ -5768,11 +5805,7 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
- child, forkCount, strerror(errno));
|
||||
- continue;
|
||||
- }
|
||||
+ if ([ud boolForKey: @"WONoDetach"])
|
||||
+ childPid = 0;
|
||||
+ else
|
||||
+ childPid = fork();
|
||||
|
||||
-
|
||||
- clientStopTime = time(NULL);
|
||||
- uptime = clientStopTime - clientStartTime;
|
||||
-
|
||||
|
@ -5835,31 +5868,9 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
- child, forkCount, status);
|
||||
- }
|
||||
- }
|
||||
+ if (childPid) {
|
||||
+ rc = 0;
|
||||
+ }
|
||||
+ else {
|
||||
+ nsPidFile = [ud objectForKey: @"WOPidFile"];
|
||||
+ if (!nsPidFile)
|
||||
+ nsPidFile = [NSString stringWithFormat: @"/var/run/%@/%@.pid",
|
||||
+ [processInfo processName],
|
||||
+ [processInfo processName]];
|
||||
+ pidFile = [nsPidFile UTF8String];
|
||||
+ if (_writePid(nsPidFile)) {
|
||||
+ respawnDelay = [ud integerForKey: @"WORespawnDelay"];
|
||||
+ if (!respawnDelay)
|
||||
+ respawnDelay = 5;
|
||||
+ /* default is to use the watch dog! */
|
||||
+ if ([ud objectForKey:@"WOUseWatchDog"] != nil
|
||||
+ && ![ud boolForKey:@"WOUseWatchDog"])
|
||||
+ rc = WOApplicationMain(appName, argc, argv);
|
||||
+ else
|
||||
+ rc = [[WOWatchDog sharedWatchDog] run: appName argc: argc argv: argv];
|
||||
}
|
||||
+ else {
|
||||
+ [ud errorWithFormat: @"unable to open pid file: %@", pidFile];
|
||||
+ rc = -1;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
- return 0;
|
||||
}
|
||||
|
@ -5876,7 +5887,7 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
}
|
||||
#endif
|
||||
|
||||
@@ -421,8 +1030,8 @@
|
||||
@@ -421,8 +1041,8 @@
|
||||
|
||||
@interface NSUserDefaults(ServerDefaults)
|
||||
+ (id)hackInServerDefaults:(NSUserDefaults *)_ud
|
||||
|
@ -5887,7 +5898,7 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
@end
|
||||
|
||||
int WOWatchDogApplicationMainWithServerDefaults
|
||||
@@ -437,7 +1046,7 @@
|
||||
@@ -437,7 +1057,7 @@
|
||||
{
|
||||
extern char **environ;
|
||||
[NSProcessInfo initializeWithArguments:(void*)argv count:argc
|
||||
|
@ -5896,7 +5907,7 @@ Index: sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m
|
|||
}
|
||||
#endif
|
||||
|
||||
@@ -446,8 +1055,8 @@
|
||||
@@ -446,8 +1066,8 @@
|
||||
|
||||
ud = [NSUserDefaults standardUserDefaults];
|
||||
sd = [defClass hackInServerDefaults:ud
|
||||
|
@ -5956,7 +5967,13 @@ Index: sope-appserver/NGObjWeb/ChangeLog
|
|||
===================================================================
|
||||
--- sope-appserver/NGObjWeb/ChangeLog (revision 1660)
|
||||
+++ sope-appserver/NGObjWeb/ChangeLog (working copy)
|
||||
@@ -1,3 +1,91 @@
|
||||
@@ -1,3 +1,97 @@
|
||||
+2009-12-22 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
+
|
||||
+ * WOWatchDogApplicationMain.m (_listeningAddress): read "WOPort"
|
||||
+ from the user defaults rather than by invoking [WOApplication
|
||||
+ port], which returns an NSNumber.
|
||||
+
|
||||
+2009-12-14 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
+
|
||||
+ * WOWatchDogApplicationMain.m (-run:argc:argv:): added a
|
||||
|
|
Loading…
Reference in New Issue