Ignore:
Timestamp:
Sep 30, 2018 11:29:21 AM (22 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
5ed701d
Parents:
b5497ef
Message:

Mac OSX Launcher: The launcher will now write the pid of the router to a file like the old wrapper did.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/SBridge.mm

    rb5497ef r410f9df  
    3737    if (anyRouterLookingProcs) {
    3838      auto errMessage = @"Seems i2p is already running - I've detected another process with i2p.jar in it's arguments.";
    39       NSLog(@"%@", errMessage);
     39      MLog(4, @"%@", errMessage);
    4040      sendUserNotification(APP_IDSTR, errMessage);
    4141      [routerStatus triggerEventWithEn:@"router_already_running" details:@"won't start - another router is running"];
     
    5454      sendUserNotification(APP_IDSTR, @"The I2P router is starting up.");
    5555      auto pid = [instance getPID];
    56       NSLog(@"Got pid: %d", pid);
     56      MLog(2, @"Got pid: %d", pid);
    5757      if (routerStatus != nil) {
    5858        // TODO: Merge events router_start and router_pid ?
    5959        [routerStatus triggerEventWithEn:@"router_start" details:@"normal start"];
    6060        [routerStatus triggerEventWithEn:@"router_pid" details:[NSString stringWithFormat:@"%d", pid]];
     61      }
     62      NSString *applicationSupportDirectory = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject];
     63      auto pidFile = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/i2p/router.pid", applicationSupportDirectory]];
     64      NSError *err;
     65     
     66      if (![[NSString stringWithFormat:@"%d", pid] writeToURL:pidFile atomically:YES encoding:NSUTF8StringEncoding error:&err]) {
     67        MLog(4, @"Error; %@", err);
     68      } else {
     69        MLog(3, @"Wrote pid file to %@", pidFile);
    6170      }
    6271     
     
    6978  {
    7079    auto errStr = [NSString stringWithFormat:@"Expection occurred %@",[e reason]];
    71     NSLog(@"%@", errStr);
     80    MLog(4, @"%@", errStr);
    7281    sendUserNotification(APP_IDSTR, errStr);
    7382    [[SBridge sharedInstance] setCurrentRouterInstance:nil];
     
    122131  RouterProcessStatus* routerStatus = [[RouterProcessStatus alloc] init];
    123132 
    124   NSString *confDir = [NSString stringWithFormat:@"%@/Application\\ Support/i2p", NSHomeDirectory()];
     133  NSString *confDir = [NSString stringWithFormat:@"%@/Library/Application\\ Support/i2p", NSHomeDirectory()];
    125134 
    126135  try {
     
    157166    NSArray* arrArguments = [NSArray arrayWithObjects:&argList[0] count:argList.size()];
    158167   
    159     NSLog(@"Trying to run command: %@", javaBinPath);
    160     NSLog(@"With I2P Base dir: %@", i2pRootPath);
    161     NSLog(@"And Arguments: %@", arrArguments);
     168    MLog(0, @"Trying to run command: %@", javaBinPath);
     169    MLog(0, @"With I2P Base dir: %@", i2pRootPath);
     170    MLog(0, @"And Arguments: %@", arrArguments);
    162171    startupRouter(nsJavaBin, arrArguments, nsBasePath, routerStatus);
    163172  } catch (std::exception &err) {
    164173    auto errMsg = [NSString stringWithUTF8String:err.what()];
    165     NSLog(@"Exception: %@", errMsg);
     174    MLog(4, @"Exception: %@", errMsg);
    166175    sendUserNotification(APP_IDSTR, [NSString stringWithFormat:@"Error: %@", errMsg]);
    167176    [routerStatus setRouterStatus: false];
Note: See TracChangeset for help on using the changeset viewer.