 
     socket.on "disconnect", () ->
         console.log "Client has disconnected, closing the processes..."
-        killCommands(commands);
+        killCommands commands
+
 
 process.on 'SIGINT', () ->
-  console.log "Server is stopping, closing the processes..."
-  killCommands(commands);
-  app.close()
-  process.exit()
+    console.log "Server is stopping, closing the processes..."
+    killCommands commands
+    app.close()
+    process.exit()
 
 process.on 'SIGTERM', () ->
-  console.log "Server is stopping, closing the processes..."
-  killCommands(commands);
-  app.close()
+    console.log "Server is stopping, closing the processes..."
+    killCommands(commands)
+    app.close()

connect = require "connect"
app = connect.createServer(connect.static('public')).listen(9099)

io = require("socket.io").listen(app)
io.set 'log level', 2 # disable heartbeat debug output

fs = require "fs"
config = require './config'
spawn = require('child_process').spawn

commands = []

sendData = (socket, data, fileName, fileSlug, channel) ->
    data = "#{data}"
    socket.emit 'new-data',

        'channel': channel
        'value': data.replace /(\[[0-9]+m)*/g, ""


# Stop given commands by sending them a SIGTERM signal.
killCommands = (commands) ->
    for fileName, command of commands
        console.log "Killing process for #{fileName}..."
        command.kill 'SIGTERM'


# Start process run a tail -f command on given file and redirect output to
# given socket.
startProcess = (socket, fileName) ->

    args = ['-f', "#{config.logPath}/#{fileName}"]
