Permalink
Browse files

add callback before exit

  • Loading branch information...
1 parent 0df6f45 commit 039e7d26f2fde317e4ab336ea2f74ecd4c8c91e9 @shimondoodkin committed Jun 28, 2010
Showing with 18 additions and 9 deletions.
  1. +9 −4 README.md
  2. +6 −3 autoexit.js
  3. +3 −2 example.js
View
@@ -16,8 +16,10 @@ Copy `autoexit.js` and `nodejs.sh` to `/var/www/`
// it is ok because this script encapsualated in a batch while(true);
// so it runs again after it exits.
var autoexit_watch=require('autoexit').watch;
- autoexit_watch(__dirname,".js");
- //autoexit_watch(__dirname+"/templates",".html");
+ //
+ var on_autoexit=function () { }
+ autoexit_watch(__dirname,".js", on_autoexit);
+ //autoexit_watch(__dirname+"/templates",".html", on_autoexit);
@@ -58,8 +60,11 @@ Copy `autoexit.js` and `nodejs.sh` to `/var/www/`
// it is ok because this script encapsualated in a batch while(true);
// so it runs again after it exits.
var autoexit_watch=require('autoexit').watch;
- autoexit_watch(__dirname,".js");
- //autoexit_watch(__dirname+"/templates",".html");
+ //
+ var on_autoexit=function () { sys.puts('bye bye'); }
+ autoexit_watch(__dirname,".js", on_autoexit);
+ //autoexit_watch(__dirname+"/templates",".html", on_autoexit);
+
View
@@ -18,12 +18,15 @@
var fs = require('fs'); // allaws to open files
var sys = require('sys'); // allows to print errors to command line
-var restart_server = function(file){
+
+function watch(parse_file_list_dirname,extention,callback) {
+
+ var restart_server = function(file){
+ if(callback)callback();
sys.puts((new Date).toTimeString()+' change discovered, restarting server. the file was: '+file);
process.exit();
-}
+ }
-function watch(parse_file_list_dirname,extention) {
var parse_file_list1 = function(dir, files, extention)
{
for (var i=0;i<files.length;i++)
View
@@ -29,8 +29,9 @@ sys.puts((new Date).toTimeString()+' Server running at http://127.0.0.1:8124/');
var autoexit_watch=require('autoexit').watch;
-autoexit_watch(__dirname,".js");
-//autoexit_watch(__dirname+"/templates",".html");
+var on_autoexit=function () { sys.puts('bye bye'); }
+autoexit_watch(__dirname,".js", on_autoexit);
+//autoexit_watch(__dirname+"/templates",".html", on_autoexit);

0 comments on commit 039e7d2

Please sign in to comment.