Skip to content

Commit

Permalink
Add boot failure handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Jul 16, 2013
1 parent 51ca10a commit 774d552
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions Tokaido/TKDApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef enum : NSUInteger {
- (void)serializeToYAML;
- (void)enterState:(TKDAppState)state;
- (void)enterSubstate:(TKDAppSubstate)substate;
- (void)setStatus:(NSString *)status;

- (void)runBundleInstall;

Expand Down
5 changes: 5 additions & 0 deletions Tokaido/TKDApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ -(void)enterState:(TKDAppState)state;
}
}

-(void)setStatus:(NSString *)status;
{
self.failureReason = status;
}

- (void)showInFinder;
{
[[NSWorkspace sharedWorkspace] openFile:self.appDirectoryPath];
Expand Down
2 changes: 1 addition & 1 deletion Tokaido/TKDMuxrManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)t
if ([reply isEqualToString:@"ADDED"]) {
NSLog(@"App added, waiting for ready...");
[self.socket readDataWithTimeout:-1 tag:0];
} else if ([reply isEqualToString:@"READY"] || [reply isEqualToString:@"REMOVED"]) {
} else if ([reply isEqualToString:@"READY"] || [reply isEqualToString:@"REMOVED"] || [reply isEqualToString:@"ERR"]) {

// This happens on a background thread, so it should fire off UI updating notifications on
// the main thread.
Expand Down
9 changes: 8 additions & 1 deletion Tokaido/TKDTokaidoController.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,17 @@ - (void)handleMuxrEvent:(NSNotification *)note
// Check the event here and do the right thing.

NSString *action = [[note userInfo] objectForKey:@"action"];

NSLog(@"ACTION: %@", action);

if ([action isEqualToString:@"ERR"]) {
[app setStatus:@"Booting failed. Review the logs or \"Open in Terminal\"."];
}

if ([action isEqualToString:@"READY"]) {
NSLog(@"Enabling App: %@", hostname);
[app enterState:TKDAppOn];
} else if ([action isEqualToString:@"FAILED"] || [action isEqualToString:@"REMOVED"]) {
} else if ([action isEqualToString:@"FAILED"] || [action isEqualToString:@"REMOVED"] || [action isEqualToString:@"ERR"]) {
NSLog(@"Disabling App: %@", hostname);
[app enterState:TKDAppOff];
}
Expand Down

0 comments on commit 774d552

Please sign in to comment.