From: Sapan Bhatia Date: Tue, 19 Jun 2007 22:21:29 +0000 (+0000) Subject: Bugfix. Crashing vsys scripts now get reported instead of failing silently X-Git-Tag: vsys-0.7-19~30 X-Git-Url: http://git.onelab.eu/?p=vsys.git;a=commitdiff_plain;h=5648b4043b34c33111800aecba36f486627a30a0 Bugfix. Crashing vsys scripts now get reported instead of failing silently --- diff --git a/backend.ml b/backend.ml index a1e86fe..1a3a432 100644 --- a/backend.ml +++ b/backend.ml @@ -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 diff --git a/dirwatcher.ml b/dirwatcher.ml index 5bd4d6c..3808e8b 100644 --- a/dirwatcher.ml +++ b/dirwatcher.ml @@ -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) diff --git a/fifowatcher.ml b/fifowatcher.ml index 51b8f99..4dbd70a 100644 --- a/fifowatcher.ml +++ b/fifowatcher.ml @@ -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 --- 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 "; if (!Globals.backend == "" || !input_file_list == []) then printf "Try vsys --help\n" diff --git a/vsys b/vsys index 44db598..eb89a80 100755 Binary files a/vsys and b/vsys differ diff --git a/vsys-initscript b/vsys-initscript index 5ade750..eb68b5d 100755 --- a/vsys-initscript +++ b/vsys-initscript @@ -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.