source: launchers/macosx/RouterTask.h @ 3c0a8cf

Last change on this file since 3c0a8cf was 3c0a8cf, checked in by meeh <meeh@…>, 21 months ago

Mac OSX Launcher: A lot of bugfixes, refactoring and cleanup.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1#pragma once
2
3#include <dispatch/dispatch.h>
4#include <memory.h>
5#include <string.h>
6
7#include <Cocoa/Cocoa.h>
8#import <AppKit/AppKit.h>
9
10#ifdef __cplusplus
11#include "include/subprocess.hpp"
12
13using namespace subprocess;
14class JavaRunner;
15
16typedef std::function<void(void)> fp_t;
17typedef std::function<void(JavaRunner *ptr)> fp_proc_t;
18
19const std::vector<NSString*> defaultStartupFlags {
20  @"-Xmx512M",
21  @"-Xms128m",
22  @"-Djava.awt.headless=true",
23  @"-Dwrapper.logfile=/tmp/router.log",
24  @"-Dwrapper.logfile.loglevel=DEBUG",
25  @"-Dwrapper.java.pidfile=/tmp/routerjvm.pid",
26  @"-Dwrapper.console.loglevel=DEBUG"
27};
28
29const std::vector<std::string> defaultFlagsForExtractorJob {
30  "-Xmx512M",
31  "-Xms128m",
32  "-Djava.awt.headless=true"
33};
34
35/**
36 *
37 * class JavaRunner
38 *
39 **/
40class JavaRunner
41{
42public:
43  // copy fn
44  JavaRunner(std::string& javaBin, std::string& arguments, std::string& i2pBaseDir, const fp_proc_t& executingFn, const fp_t& cb);
45  ~JavaRunner() = default;
46 
47  void requestRouterShutdown();
48 
49  std::future<int> execute();
50  std::shared_ptr<subprocess::Popen> javaProcess;
51  std::string javaBinaryPath;
52  std::string javaRouterArgs;
53  std::string execLine;
54  std::string _i2pBaseDir;
55private:
56  const fp_proc_t& executingFn;
57  const fp_t& exitCallbackFn;
58};
59
60#endif
61
62
63@class RTaskOptions;
64@interface RTaskOptions : NSObject
65@property (strong) NSString* binPath;
66@property (strong) NSArray<NSString *>* arguments;
67@property (strong) NSString* i2pBaseDir;
68@end
69
70@class I2PRouterTask;
71@interface I2PRouterTask : NSObject
72@property (strong) NSTask* routerTask;
73@property (strong) NSUserDefaults *userPreferences;
74@property (strong) NSFileHandle *readLogHandle;
75@property (strong) NSMutableData *totalLogData;
76@property (strong) NSPipe *processPipe;
77@property (strong) NSFileHandle *input;
78@property (atomic) BOOL isRouterRunning;
79@property (atomic) BOOL userRequestedRestart;
80- (instancetype) initWithOptions : (RTaskOptions*) options;
81- (int) execute;
82- (void) requestShutdown;
83- (void) requestRestart;
84- (BOOL) isRunning;
85- (int) getPID;
86- (void)routerStdoutData:(NSNotification *)notification;
87@end
88
89
90
91
92
93
Note: See TracBrowser for help on using the repository browser.