 fs = require 'fs'
 url = require 'url'
 path = require 'path'
-spawn = require('child_process').spawn
+child_process = require 'child_process'
 
 PICAM_UID = 1000
 PICAM_CWD = path.normalize "#{__dirname}/.."

process.on 'SIGINT', ->
  console.log "Got SIGINT. Sending SIGINT to picam"
  if DO_SPAWN_PICAM and picam?
    picam.kill 'SIGINT'
  else
    process.kill process.pid, 'SIGTERM'


startStreamProcess = ->
  console.log "spawning picam"
  # ionice: -c1 (realtime) -n0 (highest priority)
  picam = child_process.spawn 'nice', [
    '-n', '-20', 'ionice', '-c1', '-n0', 'sudo', '-u', "##{PICAM_UID}",
    # picam command options
    PICAM_PATH, '--rtspout', '--alsadev', 'hw:1,0',
