source: launchers/macosx/obj-cpp/JavaRunner.h @ 21b3864

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

Moved some logic to C++, which will extract i2p if it's not already,
and then secondly fire up the router in a second java process when
extraction is completed. Gonna use "optional" type in C++ to make
global variables a bit less painful to use.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#pragma once
2
3#include <dispatch/dispatch.h>
4#include <functional>
5#include <memory>
6#include <string>
7#include <list>
8
9#include <subprocess.hpp>
10#include <optional.hpp>
11
12using namespace subprocess;
13using namespace std::experimental;
14
15class JavaRunner;
16
17struct CRouterState
18{
19  enum State {
20    C_STOPPED = 0,
21    C_STARTED,
22    C_RUNNING
23  };
24};
25
26typedef std::function<void(void)> fp_t;
27typedef std::function<void(JavaRunner *ptr)> fp_proc_t;
28
29/**
30 *
31 * class JavaRunner
32 *
33 **/
34class JavaRunner
35{
36public:
37  // copy fn
38  JavaRunner(std::string javaBin, const fp_proc_t& executingFn, const fp_t& cb);
39  ~JavaRunner() = default;
40
41  const std::list<std::string> defaultStartupFlags {
42    "-Xmx512M",
43    "-Xms128m",
44    "-Djava.awt.headless=true",
45    "-Dwrapper.logfile=/tmp/router.log",
46    "-Dwrapper.logfile.loglevel=DEBUG",
47    "-Dwrapper.java.pidfile=/tmp/routerjvm.pid",
48    "-Dwrapper.console.loglevel=DEBUG",
49    "-Di2p.dir.base=$BASEPATH",
50    "-Djava.library.path=$BASEPATH",
51    "$JAVA_OPTS",
52    "net.i2p.launchers.SimpleOSXLauncher"
53  };
54
55  const std::list<std::string> defaultFlagsForExtractorJob {
56    "-Xmx512M",
57    "-Xms128m",
58    "-Djava.awt.headless=true",
59    "-Di2p.dir.base=$BASEPATH",
60    "-Di2p.dir.zip=$ZIPPATH",
61    "net.i2p.launchers.BaseExtractor",
62    "extract"
63  };
64
65  optional<std::future<int> > execute();
66  std::shared_ptr<Popen> javaProcess;
67  std::string javaBinaryPath;
68private:
69  const fp_proc_t& executingFn;
70  const fp_t& exitCallbackFn;
71};
72
Note: See TracBrowser for help on using the repository browser.