Skip to content

Commit

Permalink
Initial code.
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed May 26, 2013
1 parent ee29644 commit abfcaea
Show file tree
Hide file tree
Showing 13 changed files with 1,282 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
support
test
example
docs
Gruntfile.js
*.sock
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2013 Corey Butler <corey@coreybutler.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node-linux
==========
# node-linux

Create native background daemons on Linux systems.

Currently being built.
15 changes: 15 additions & 0 deletions example/helloworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(JSON.stringify(process.env));
//res.end('Hello World\n');
});

server.listen(3000);
console.log('Server running at http://127.0.0.1:3000/');

// Force the process to close after 15 seconds
setTimeout(function(){
throw 'A test Error'
//process.exit();
},25000);
35 changes: 35 additions & 0 deletions example/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var Service = require('../').Service;

// Create a new service object
var svc = new Service({
name:'Hello World',
description: 'The nodejs.org example web server.',
script: require('path').join(__dirname,'helloworld.js'),
env:{
name: "NODE_ENV",
value: "production"
}
});

// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
console.log('\nInstallation Complete\n---------------------');
svc.start();
});

// Just in case this file is run twice.
svc.on('alreadyinstalled',function(){
console.log('This service is already installed.');
console.log('Attempting to start it.');
svc.start();
});

// Listen for the "start" event and let us know when the
// process has actually started working.
svc.on('start',function(){
console.log(svc.name+' started!\nVisit http://127.0.0.1:3000 to see it in action.\n');
});

// Install the script as a service.
svc.install();
16 changes: 16 additions & 0 deletions example/uninstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var Service = require('../').Service;

// Create a new service object
var svc = new Service({
name:'Hello World',
script: require('path').join(__dirname,'helloworld.js')
});

// Listen for the "uninstall" event so we know when it's done.
svc.on('uninstall',function(){
console.log('Uninstall complete.');
console.log('The service exists: ',svc.exists);
});

// Uninstall the service.
svc.uninstall();
Loading

0 comments on commit abfcaea

Please sign in to comment.