#!/usr/bin/env bash # Spectre 2 # # Douglas Thrift # # $Id$ command="$1" shift function check() { pid="$(< spectre.pid)" } function usage() { echo "Usage: $(basename $0) start|stop|restart|reload|status [...]" } function start_() { echo -n "Starting Spectre daemon ... " $(dirname $0)/Spectre2 -fork $@ echo "started." } function stop_() { echo -n "Stopping Spectre daemon ... " # try # { # pid_t id(process()); # # api::Posix::CheckError(::kill(id, SIGTERM)); # # // XXX: somehow wait for it to terminate # # api::Cout << "stopped." << ios::NewLine; # } # catch (ext::Exception) { api::Cout << "failed." << ios::NewLine; } } function reload_() { echo -n "Reloading Spectre daemon ... " # api::Cout << "Reloading Spectre daemon ... " << ios::Flush; # # try # { # api::Posix::CheckError(::kill(process(), SIGUSR1)); # # api::Cout << "reloaded." << ios::NewLine; # } # catch (ext::Exception) { api::Cout << "failed." << ios::NewLine; } } function status_() { echo "STUB: status_()" } case $command in start) start_ $@ ;; stop) stop_ ;; restart) restart_ $@ ;; reload) reload_ ;; status) status_ ;; *) usage ;; esac