Bugfix. Crashing vsys scripts now get reported instead of failing silently
authorSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 19 Jun 2007 22:21:29 +0000 (22:21 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Tue, 19 Jun 2007 22:21:29 +0000 (22:21 +0000)
backend.ml
dirwatcher.ml
fifowatcher.ml
main.ml
vsys
vsys-initscript

index a1e86fe..1a3a432 100644 (file)
@@ -32,7 +32,7 @@ let rec list_check lst elt =
 class backendHandler dir_root (frontend_lst: frontendHandler list) =
         let mk_rel_path = delete_prefix dir_root in object(this)
 
-  val file_regexp = ref (Str.regexp "[a-zA-Z][a-zA-Z0-9_-'.']*")
+  val file_regexp = ref (Str.regexp "[a-zA-Z][a-zA-Z0-9_'.']*")
 
   method new_dir fqp func =
     let s = Unix.stat fqp in
index 5bd4d6c..3808e8b 100644 (file)
@@ -20,7 +20,7 @@ let handle_dir_event dirname evlist str =
         flush Pervasives.stdout
 
 let add_watch dir events handler =
-  printf "Adding watch for %s\n" dir;
+  printf "Adding watch for %s\n" dir;flush Pervasives.stdout;
   let wd = Inotify.add_watch fd dir events in
       Hashtbl.add wdmap wd (dir,handler)
 
index 51b8f99..4dbd70a 100644 (file)
@@ -38,7 +38,7 @@ let receive_process_event (idesc:fd_and_fname) (_:fd_and_fname) =
                   printf "Here: %d %s\n" !count curline;flush Pervasives.stdout;
                   fprintf fifo_outchan "%s\n" curline;flush fifo_outchan
               with 
-                | End_of_file|Sys_blocked_io|Unix_error(EPIPE,_,_) ->
+                | End_of_file|Sys_blocked_io|Unix_error(EPIPE,_,_)|Unix_error(EBADF,_,_) ->
                     begin
                       cont:=false
                     end
diff --git a/main.ml b/main.ml
index 2bf4c8c..2d4057d 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -18,7 +18,7 @@ let cmdspeclist =
 let cont = ref true
 
 let _ =
-  printf "Vsys v0.3\n";flush stdout;
+  printf "Vsys v0.4\n";flush stdout;
   Arg.parse cmdspeclist (fun x->()) "Usage: vsys <list of mount points>";  
   if (!Globals.backend == "" || !input_file_list == []) then
       printf "Try vsys --help\n"
diff --git a/vsys b/vsys
index 44db598..eb89a80 100755 (executable)
Binary files a/vsys and b/vsys differ
index 5ade750..eb68b5d 100755 (executable)
@@ -1,15 +1,28 @@
 #!/bin/bash
+# vsys initscript
+# Author: sapanb
+
+backend="/vsys"
 
 case "$1" in
-    start|restart|reload|update)
-       ;;
-    stop|status)
-       exit 0
-       ;;
+    start)
+        echo -n "Starting vsys:"
+        if [ ! -d $backend ]; then mkdir $backend; fi
+        find /vservers -maxdepth 1 -type d | perl -e 'while (<>) {if (/(\/vservers\/(.*_.*))/) {$dir=$1;if (not (-d "$dir/vsys")) {mkdir "$dir/vsys";}}}'
+        frontends=`find /vservers -maxdepth 1 -type d | perl -e 'while (<>) {if (/(\/vservers\/(.*_.*))/) {$dir=$1;$slice=$2;printf "-frontend $dir $slice "}}'`
+        vsys_command="/usr/bin/vsys -backend $backend $frontends"
+        echo $vsys_command
+        $vsys_command
+        ;;
+    stop)
+        echo -n "Stopping $prog:"
+        killall vsys
+        exit 0
+        ;;
     *)
-       echo $"Usage: $0 {start|stop|restart|status}"
-       exit 1
-       ;;
+        echo $"Usage: $0 {start|stop}"
+        exit 1
+        ;;
 esac
 
 # Source function library.