
console.log("Starting Emergin Gateway");

"use-strict"

var http = require("http");
var utils = require("utils");
var config = require("Config");
var ssl = require("SSL");
var server = require("HTTPServer");
var publisher = require("Publisher");


if (config.gatewayPIDFile && config.gatewayPIDFile.length > 0) {
  if (!system.write_pid_file(config.gatewayPIDFile, true)) {
    console.log("Unable to write PID file " + config.gatewayPIDFile);
    system.exit(-1);
  }
}

//
// Initalize SSL certificates
//
ssl.initialize(http, config);

//
// Intialize ZeroMQ Event Publisher
//
publisher.initialize(config);

//
// Initialize HTTP Server
//
server.initialize(http, config, publisher);

