ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Spectre2/Spectre2Control
(Generate patch)

Comparing Spectre2/Spectre2Control (file contents):
Revision 418 by douglas, 2005-03-02T22:36:24-08:00 vs.
Revision 428 by douglas, 2005-03-24T17:38:00-08:00

# Line 11 | Line 11 | shift
11  
12   function check()
13   {
14 <        pid="$(< spectre.pid)"
14 >        pid="$($(dirname $0)/Spectre2 -pid $@)"
15 >        if [ "$pid" = "" ]; then
16 >                echo "not running."
17 >                exit
18 >        fi
19   }
20  
21   function usage()
# Line 22 | Line 26 | function usage()
26   function start_()
27   {
28          echo -n "Starting Spectre daemon ... "
29 +        if [ "$($(dirname $0)/Spectre2 -pid $@)" != "" ]; then
30 +                echo "already running."
31 +                exit
32 +        fi
33          $(dirname $0)/Spectre2 -fork $@
34          echo "started."
35   }
# Line 29 | Line 37 | function start_()
37   function stop_()
38   {
39          echo -n "Stopping Spectre daemon ... "
40 < #       try
41 < #       {
42 < #               pid_t id(process());
43 < #
44 < #               api::Posix::CheckError(::kill(id, SIGTERM));
45 < #
46 < #               // XXX: somehow wait for it to terminate
47 < #
48 < #               api::Cout << "stopped." << ios::NewLine;
49 < #       }
50 < #       catch (ext::Exception) { api::Cout << "failed." << ios::NewLine; }
40 >        check $@
41 >        kill -TERM $pid
42 >        until [ "$($(dirname $0)/Spectre2 -pid $@)" == "" ]; do
43 >                sleep 0;
44 >        done
45 >        echo "stopped."
46 > }
47 >
48 > function restart_()
49 > {
50 >        stop_ $@
51 >        start_ $@
52   }
53  
54   function reload_()
55   {
56          echo -n "Reloading Spectre daemon ... "
57 < #       api::Cout << "Reloading Spectre daemon ... " << ios::Flush;
58 < #
59 < #       try
51 < #       {
52 < #               api::Posix::CheckError(::kill(process(), SIGUSR1));
53 < #
54 < #               api::Cout << "reloaded." << ios::NewLine;
55 < #       }
56 < #       catch (ext::Exception) { api::Cout << "failed." << ios::NewLine; }
57 >        check $@
58 >        kill -USR1 $pid
59 >        echo "reloaded."
60   }
61  
62   function status_()
63   {
64 <        echo "STUB: status_()"
64 >        echo -n "Checking Spectre daemon ... "
65 >        check $@
66 >        echo "running with PID $pid."
67   }
68  
69   case $command in
# Line 66 | Line 71 | start)
71          start_ $@
72          ;;
73   stop)
74 <        stop_
74 >        stop_ $@
75          ;;
76   restart)
77          restart_ $@
78          ;;
79   reload)
80 <        reload_
80 >        reload_ $@
81          ;;
82   status)
83 <        status_
83 >        status_ $@
84          ;;
85   *)
86          usage

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines