Add support for restarting a process via API

This commit is contained in:
Richard Frith-Macdonald 2022-11-14 12:51:39 +00:00
parent d28d019bb5
commit 31b74e74c7
3 changed files with 34 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2022-11-14 Richard Frith-Macdonald <rfm@gnu.org>
* EcProcess.h:
* EcCommand.m:
Add new method of Command server (-restart:reason:) to requst that
it restart an individual process.
2022-11-11 Richard Frith-Macdonald <rfm@gnu.org>
* EcCommand.m:

View file

@ -5928,6 +5928,26 @@ NSLog(@"Problem %@", localException);
}
}
- (BOOL) restart: (NSString*)name reason: (NSString*)reason
{
LaunchInfo *l = [LaunchInfo existing: name];
if (nil == l)
{
NSString *m;
m = [NSString stringWithFormat: cmdLogFormat(LT_CONSOLE,
@"unrecognized name to restart %@"), name];
[self information: m from: nil to: nil type: LT_CONSOLE];
return NO;
}
else
{
[l restart: reason];
}
return YES;
}
- (NSString*) makeSpace
{
NSInteger purgeAfter;

View file

@ -262,6 +262,12 @@ typedef enum {
to: (NSString*)n
from: (NSString*)c;
/** Request immediate restart of the named process.<br />
* The reason string is displayed in reporting etc.<br />
* Returns YES if the process was found, NO otherwise.
*/
- (BOOL) restart: (NSString*)name reason: (NSString*)reason;
/** Shut down the Command server and all its clients.<br />
* Clients which fail to shut down gracefully before the specified timestamp
* will be forcibly killed. The timestamp is constrained to be at least half
@ -308,6 +314,7 @@ typedef enum {
- (oneway void) reply: (NSString*)msg
to: (NSString*)n
from: (NSString*)c;
- (BOOL) restart: (NSString*)name reason: (NSString*)reason;
- (oneway void) servers: (in bycopy NSData*)a
on: (id<Command>)s;
- (oneway void) unmanage: (NSString*)name;