 
 
 setup = (options = {}) ->
+
   console.log "To start/stop watching memory profiling send SIGUSR2 to PID #{process.pid}"
 
   { AWS_KEY, AWS_SECRET } = options

  # take an initial snapshot
  latestHeapSnapshot = { content: v8profiler.takeSnapshot(), date: Date.now() }

  # then take a heap snapshot every second
  snapshotInterval = setInterval ->
    latestHeapSnapshot = { content: v8profiler.takeSnapshot(), date: Date.now() }
  , 1000

  memwatch.on 'leak', handleSnapshots
  console.log "Started watching possible memory leakage for the process with id #{process.pid}"

memwatch   = require 'memwatch'
v8profiler = require 'v8-profiler'

state              = off
bucket             = 'koding-nodejs-runtime-heapsnapshots'
snapshotInterval   = null
latestHeapSnapshot = {}

handleSnapshots = (info) ->

