Skip to content
Browse files

'forever' changes the current working directory, so use __dirname ins…

…tead. That only took all day...
  • Loading branch information...
1 parent f1756db commit 2970bfea5c03987d16e7e96268d90d4da822704a @boutell boutell committed Apr 23, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 example/server.js
5 example/server.js
@@ -6,7 +6,10 @@ var http = require('http');
var fs = require('fs');
// Get the port number from data/port. Watch out for trailing whitespace
-var port = fs.readFileSync('data/port', 'UTF-8').replace(/\s+$/, '');
+// 'forever' may change the current working directory on us when we use a full path,
+// so use __dirname to locate ourselves instead
+var port = fs.readFileSync(__dirname + '/data/port', 'UTF-8').replace(/\s+$/, '');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});

0 comments on commit 2970bfe

Please sign in to comment.
Something went wrong with that request. Please try again.