       enabled: true
   log "addRmTask #{path}"
 
-doSpawn = (task, cmd, args, cwd, dolog, continuation) ->
+doSpawn = (task, cmd, args, cwd, dolog, continuation, logfilename) ->
   log "doSpawn: #{cmd} #{JSON.stringify args} in #{cwd}"
   if dolog
     try
-      out = fs.openSync("#{cwd}/out.log", 'a')
-      err = fs.openSync("#{cwd}/out.log", 'a')
+      logfilename = logfilename ? 'out.log'
+      out = fs.openSync("#{cwd}/#{logfilename}", 'a')
+      err = fs.openSync("#{cwd}/#{logfilename}", 'a')
       logstdio = [ 'ignore', out, err ]
     catch err
       log "doSpawn: error opening log file #{err.message}"

    catch err
      return taskError task, "Error writing server conf #{path}: #{err.message}"
    htpasswd = "# admins for mediahub server #{serverId} - #{server.title}\n"
    for admin in (server.admins ? [])
      password = ssha (admin.password ? '')
      htpasswd = htpasswd+admin.username+':'+password+'\n'
    try 
      log "Write nginx htpasswd for #{serverId} #{htpasswdpath}"
      fs.writeFileSync htpasswdpath, htpasswd, encoding:'utf8'
    catch err
      return taskError task, "Error writing server htpasswd #{htpasswdpath}: #{err.message}"
    # kick nginx...
    log "** FORCE NGINX CONFIG RELOAD - probably fails in dev mode! **"
    doSpawn task, "nginx", ["-s", "reload"], SERVERDIR, true,

          updateServerNginx task

# https://gist.github.com/itorres/2947088
# Note: doesn't seem to work (i.e. authenticate user) with nginx
crypto = require('crypto')
ssha = (cleartext, salt) ->
  try 
