JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
add hack to fix current working directory on nodester
[peach-cgt.git] / server.coffee
index 1ce56f2..b1cdac9 100644 (file)
@@ -104,7 +104,7 @@ js_handler = (args, out, request, url_parts) ->
 html_handler = (args, out, request, url_parts) ->
        fs.readFile 'index.html', 'utf8', (err, data) ->
                if err
-                       return out.end 'Server failed to read index.html'
+                       return out.end "Server failed to read index.html: #{err}"
                out.end data
 
 clean_pathname_regex = new RegExp('[^a-zA-Z/_.-]')
@@ -301,6 +301,11 @@ http_server = http.createServer (req, res) ->
 
        return html_handler url_parts.query, res, req, url_parts
 
+################## INIT ####################
+# nodester starts this app with the current working directory set to / and working copy in /app
+if process.cwd() is '/'
+       process.chdir '/app'
+
 setInterval expire_old_games, 2 * 60 * 1000 # check every 2 minutes for expired games
 
 http_server.listen listen_port, "127.0.0.1"