source: launchers/macosx/src/main/scala/net/i2p/launchers/osx/MacOSXRouterLauncher.scala @ d4dd0ea

Last change on this file since d4dd0ea was d4dd0ea, checked in by meeh <meeh@…>, 2 years ago

Adjustments in Scala code to adopt to work with the Obj-C++ code.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package net.i2p.launchers.osx
2
3import java.io.File
4import java.lang.reflect.Field
5
6import scala.sys.process.Process
7import net.i2p.launchers.RouterLauncher
8
9import scala.concurrent.Future
10import scala.concurrent.ExecutionContext.Implicits.global
11
12/**
13  *
14  *
15  * @author Meeh
16  * @since 0.9.35
17  */
18object MacOSXRouterLauncher extends RouterLauncher {
19
20  // ??? equals "throw not implemented" IIRC - it compiles at least :)
21  override def runRouter(args: Array[String]): Future[Process] = ???
22
23  def runRouter(basePath: File, args: Array[String]): Future[Process] = {
24    Future {
25      lazy val javaOpts = Seq(
26        "-Xmx512M",
27        "-Xms128m",
28        "-Djava.awt.headless=true",
29        "-Dwrapper.logfile=/tmp/router.log",
30        "-Dwrapper.logfile.loglevel=DEBUG",
31        "-Dwrapper.java.pidfile=/tmp/routerjvm.pid",
32        "-Dwrapper.console.loglevel=DEBUG",
33        s"-Di2p.dir.base=${basePath}",
34        s"-Djava.library.path=${basePath}"
35      )
36      val javaOptsString = javaOpts.map(_ + " ").mkString
37      val cli = s"""java -cp "${new File(basePath, "lib").listFiles().map{f => f.toPath.toString.concat(":")}.mkString}." ${javaOptsString} net.i2p.router.Router"""
38      println(s"CLI => ${cli}")
39      val pb = Process(cli)
40      // Use "run" to let it fork in behind
41      pb.run
42    }
43  }
44}
45
Note: See TracBrowser for help on using the repository browser.