Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…tead. That only took all day...
  • Loading branch information...
commit 2970bfea5c03987d16e7e96268d90d4da822704a 1 parent f1756db
@boutell boutell authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 example/server.js
View
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'});
Please sign in to comment.
Something went wrong with that request. Please try again.