- Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathexample.js
More file actions
Latest commit
37 lines (30 loc) · 725 Bytes
/
Copy pathexample.js
File metadata and controls
37 lines (30 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
vardaemon=require('./daemon');
varfs=require('fs');
varhttp=require('http');
varsys=require('sys');
varconfig={
lockFile: '/tmp/testd.pid'//Location of lockFile
};
varargs=process.argv;
vardPID;
// Handle start stop commands
switch(args[2]){
case"stop":
process.kill(parseInt(fs.readFileSync(config.lockFile)));
process.exit(0);
break;
case"start":
dPID=daemon.start();
daemon.lock(config.lockFile);
daemon.closeIO();
break;
default:
sys.puts('Usage: [start|stop]');
process.exit(0);
}
// Start HTTP Server
http.createServer(function(req,res){
res.writeHead(200,{'Content-Type': 'text/html'});
res.write('<h1>Hello, World!</h1>');
res.close();
}).listen(8000);