Sha256: d9a6ffe6c8d4b4da9bd2afe3c5ddb34386ef721fd732dc0c31a32d04c49b92f3

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

import Foundation

import Kitura
import KituraSys
import KituraNet
import HeliumLogger
import LoggerAPI
import SwiftyJSON

import StatsD
import <%= application_name %>

var config: JSON? = nil
var statsD: StatsD? = nil
var router: Router? = nil

private func setupLogger() {
  Log.logger = HeliumLogger()
}

// Load the config from the json file
private func loadConfig() -> JSON? {
  if Process.arguments.count < 2 {
    Log.error("Please specify config file")

    return nil
  }

  if let jsonData = NSData(contentsOfFile: Process.arguments[1])
  {
    let config = JSON(data: jsonData)
    Log.info("Loaded config: \(config)")

    return config
  } else {
    Log.error("Unable to load config")

    return nil
  }
}

setupLogger()
config = loadConfig()
statsD = Metrics().setupStatsD()
router = Routing(statsD: statsD!, config: config!).setupRouter()

Log.info("Starting Server on port 8090:")
statsD!.increment(bucket: "\(Buckets.Application.rawValue).\(Buckets.Started.rawValue)")

let server = HTTPServer.listen(port: 8090, delegate: router!)
Server.run()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
minke-generator-swift-0.1.4 lib/generators/swift/scaffold/src/<%= application_name %>App/main.swift.erb
minke-generator-swift-0.1.0 lib/generators/swift/scaffold/src/<%= application_name %>App/main.swift.erb