Changeset 2233f7f for launchers/macosx/SBridge.mm
- Timestamp:
- Sep 30, 2018 9:40:43 AM (2 years ago)
- Branches:
- master
- Children:
- b5497ef
- Parents:
- 36b758f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
launchers/macosx/SBridge.mm
r36b758f r2233f7f 21 21 #import <AppKit/AppKit.h> 22 22 #import "I2PLauncher-Swift.h" 23 #include "LoggerWorker.hpp" 24 #include "Logger.h" 25 #include "logger_c.h" 23 26 24 27 #include "AppDelegate.h" … … 29 32 std::future<int> startupRouter(NSString* javaBin, NSArray<NSString*>* arguments, NSString* i2pBaseDir, RouterProcessStatus* routerStatus) { 30 33 @try { 31 RTaskOptions* options = [RTaskOptions alloc]; 32 options.binPath = javaBin; 33 options.arguments = arguments; 34 options.i2pBaseDir = i2pBaseDir; 35 auto instance = [[I2PRouterTask alloc] initWithOptions: options]; 36 37 [[SBridge sharedInstance] setCurrentRouterInstance:instance]; 38 [instance execute]; 39 sendUserNotification(APP_IDSTR, @"The I2P router is starting up."); 40 auto pid = [instance getPID]; 41 NSLog(@"Got pid: %d", pid); 42 if (routerStatus != nil) { 43 [routerStatus setRouterStatus: true]; 44 [routerStatus setRouterRanByUs: true]; 45 [routerStatus triggerEventWithEn:@"router_start" details:@"normal start"]; 46 [routerStatus triggerEventWithEn:@"router_pid" details:[NSString stringWithFormat:@"%d", pid]]; 34 IIProcessInfo* processInfoObj = [[IIProcessInfo alloc] init]; 35 [processInfoObj obtainFreshProcessList]; 36 auto anyRouterLookingProcs = [processInfoObj findProcessWithStringInNameOrArguments:@"i2p.jar"]; 37 if (anyRouterLookingProcs) { 38 auto errMessage = @"Seems i2p is already running - I've detected another process with i2p.jar in it's arguments."; 39 NSLog(@"%@", errMessage); 40 sendUserNotification(APP_IDSTR, errMessage); 41 [routerStatus triggerEventWithEn:@"router_already_running" details:@"won't start - another router is running"]; 42 return std::async(std::launch::async, []{ 43 return -1; 44 }); 45 } else { 46 RTaskOptions* options = [RTaskOptions alloc]; 47 options.binPath = javaBin; 48 options.arguments = arguments; 49 options.i2pBaseDir = i2pBaseDir; 50 auto instance = [[I2PRouterTask alloc] initWithOptions: options]; 51 52 [[SBridge sharedInstance] setCurrentRouterInstance:instance]; 53 [instance execute]; 54 sendUserNotification(APP_IDSTR, @"The I2P router is starting up."); 55 auto pid = [instance getPID]; 56 NSLog(@"Got pid: %d", pid); 57 if (routerStatus != nil) { 58 // TODO: Merge events router_start and router_pid ? 59 [routerStatus triggerEventWithEn:@"router_start" details:@"normal start"]; 60 [routerStatus triggerEventWithEn:@"router_pid" details:[NSString stringWithFormat:@"%d", pid]]; 61 } 62 63 return std::async(std::launch::async, [&pid]{ 64 return pid; 65 }); 47 66 } 48 49 return std::async(std::launch::async, [&pid]{50 return pid;51 });52 67 } 53 68 @catch (NSException *e) … … 93 108 auto jarList = buildClassPathForObjC(basePath); 94 109 const char * classpath = jarList.c_str(); 95 NSLog(@"Classpath from ObjC = %s", classpath);110 MLog(0, @"Classpath from ObjC = %s", classpath); 96 111 return [[NSString alloc] initWithUTF8String:classpath]; 97 112 } … … 106 121 107 122 RouterProcessStatus* routerStatus = [[RouterProcessStatus alloc] init]; 123 124 NSString *confDir = [NSString stringWithFormat:@"%@/Application\\ Support/i2p", NSHomeDirectory()]; 125 108 126 try { 109 127 std::vector<NSString*> argList = { … … 111 129 @"-Xms128m", 112 130 @"-Djava.awt.headless=true", 113 @"-Dwrapper.logfile=/tmp/router.log",131 [NSString stringWithFormat:@"-Dwrapper.logfile=%@/router.log", [NSString stringWithUTF8String:getDefaultLogDir().c_str()]], 114 132 @"-Dwrapper.logfile.loglevel=DEBUG", 115 @"-Dwrapper.java.pidfile=/tmp/routerjvm.pid",133 [NSString stringWithFormat:@"-Dwrapper.java.pidfile=%@/router.pid", confDir], 116 134 @"-Dwrapper.console.loglevel=DEBUG" 117 135 };
Note: See TracChangeset
for help on using the changeset viewer.