All Downloads are FREE. Search and download functionalities are using the official Maven repository.

os.engine.internal.IEngine.scala Maven / Gradle / Ivy

The newest version!
// Copyright AGPL3+ 2015 ~ Optersoft SL

package os.engine.internal

import java.net.InetAddress
import os.engine.internal.http.HttpServer
import os.io.Directory
import java.util.concurrent.atomic.AtomicBoolean
import os.engine.HttpEvent
import os.engine.Module

// https://github.com/hyperic/sigar

// cluster -> https://github.com/kuujo/vertigo

object IEngine {

  private val init = new AtomicBoolean

  def addModule(module: Module) = IModule.addModule(module)

  def start() {

    if (init.getAndSet(true))
      return

    HttpServer.start()

  }

  def stop() {

    HttpServer.stop()
  }

  private lazy val config = getConfig()

  //lazy val cluster: Cluster = new os.engine.internal.cluster.Cluster(config)

  /////

  private val shutdownHook = new Thread {
    override def run() { IEngine.stop() }
  }

  Runtime.getRuntime().addShutdownHook(new Thread {
    override def run() {}
  })

  protected def getConfig(): Config = {

    val hostName = InetAddress.getLocalHost().getHostName()

    new Config(hostName, "127.0.0.1", 5700, Directory.UserHome / "engine")
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy