starting and stopping the scheduler daemon works now, like a charm
see http://bugs.campware.org/view.php?id=469
This commit is contained in:
parent
c9e68edff6
commit
145e0da83f
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: maroy $
|
||||
# Version : $Revision: 1.27 $
|
||||
# Version : $Revision: 1.28 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -265,6 +265,7 @@ start: ${SCHEDULER_EXE}
|
|||
|
||||
stop: ${SCHEDULER_EXE}
|
||||
${SCHEDULER_EXE} -c ${SCHEDULER_CFG} stop
|
||||
sleep 2
|
||||
|
||||
status: ${SCHEDULER_EXE}
|
||||
${SCHEDULER_EXE} -c ${SCHEDULER_CFG} status
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.8 $
|
||||
Version : $Revision: 1.9 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -190,7 +190,7 @@ SchedulerDaemon :: configure(const xmlpp::Element & element)
|
|||
sf->getSchedule(),
|
||||
audioPlayer));
|
||||
// TODO: read granularity from config file
|
||||
granularity.reset(new time_duration(seconds(30)));
|
||||
granularity.reset(new time_duration(seconds(1)));
|
||||
|
||||
eventScheduler.reset(
|
||||
new LiveSupport::EventScheduler::EventScheduler(eventContainer,
|
||||
|
@ -239,27 +239,27 @@ SchedulerDaemon :: uninstall(void) throw (std::exception)
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Start the scheduler daemon.
|
||||
* Execute daemon startup functions.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemon :: start(void) throw (std::logic_error)
|
||||
SchedulerDaemon :: startup (void) throw ()
|
||||
{
|
||||
XmlRpcDaemon::start();
|
||||
audioPlayer->initialize();
|
||||
eventScheduler->start();
|
||||
XmlRpcDaemon::startup();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Stop the scheduler daemon.
|
||||
* Shut down the daemon
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SchedulerDaemon :: stop(void) throw (std::logic_error)
|
||||
SchedulerDaemon :: shutdown(void) throw (std::logic_error)
|
||||
{
|
||||
eventScheduler->stop();
|
||||
audioPlayer->deInitialize();
|
||||
|
||||
XmlRpcDaemon::stop();
|
||||
XmlRpcDaemon::shutdown();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -124,7 +124,7 @@ using namespace LiveSupport::PlaylistExecutor;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.7 $
|
||||
* @version $Revision: 1.8 $
|
||||
* @see ConnectionManagerFactory
|
||||
* @see StorageClientFactory
|
||||
* @see ScheduleFactory
|
||||
|
@ -191,6 +191,16 @@ class SchedulerDaemon : public Installable,
|
|||
registerXmlRpcFunctions(Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||
throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Execute any calls when the daemon is starting up.
|
||||
* All resources allocated here should be freed up in shutdown().
|
||||
*
|
||||
* @see #shutdown
|
||||
*/
|
||||
virtual void
|
||||
startup (void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -246,23 +256,16 @@ class SchedulerDaemon : public Installable,
|
|||
uninstall(void) throw (std::exception);
|
||||
|
||||
/**
|
||||
* Start the daemon.
|
||||
* Shut down the daemon.
|
||||
* This function is public only because the signal handler
|
||||
* needs visibility to this function, which will call it.
|
||||
* A call to stop() will trigger a signal that will call shutdown().
|
||||
*
|
||||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
*/
|
||||
virtual void
|
||||
start (void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Stop the daemon.
|
||||
*
|
||||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
*/
|
||||
virtual void
|
||||
stop (void) throw (std::logic_error);
|
||||
|
||||
shutdown (void) throw (std::logic_error);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SignalDispatcher.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -131,12 +131,17 @@ SignalDispatcher :: removeHandler(
|
|||
::signal(signal, SIG_DFL);
|
||||
}
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Our signal dispatcher
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SignalDispatcher :: dispatcher(int signal) throw ()
|
||||
{
|
||||
std::cerr << "dispatcher called with signal " << signal << std::endl;
|
||||
std::cerr << "handler for this signal: " << handlers[signal] << std::endl;
|
||||
handlers[signal]->handleSignal(signal);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/XmlRpcDaemon.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -227,7 +227,7 @@ XmlRpcDaemon :: daemonize(void) throw (std::runtime_error)
|
|||
signalDispatcher->registerHandler(SIGHUP, handler);
|
||||
signalDispatcher->registerHandler(SIGTERM, handler);
|
||||
// FIXME: this signal handler will not be deleted by anyone,
|
||||
// poddible memory leak
|
||||
// possible memory leak
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -281,6 +281,16 @@ XmlRpcDaemon :: start (void) throw (std::logic_error)
|
|||
}
|
||||
}
|
||||
|
||||
startup();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Execute any daemon startup calls.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
XmlRpcDaemon :: startup (void) throw ()
|
||||
{
|
||||
// and now our own XML-RPC methods
|
||||
registerXmlRpcFunctions(xmlRpcServer);
|
||||
|
||||
|
@ -322,7 +332,9 @@ XmlRpcDaemon :: stop (void) throw (std::logic_error)
|
|||
checkForConfiguration();
|
||||
|
||||
pid_t pid = loadPid();
|
||||
kill(pid, SIGTERM);
|
||||
if (pid) {
|
||||
kill(pid, SIGTERM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/XmlRpcDaemon.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -119,7 +119,7 @@ using namespace LiveSupport::Core;
|
|||
*
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
class XmlRpcDaemon
|
||||
{
|
||||
|
@ -248,6 +248,18 @@ class XmlRpcDaemon
|
|||
throw (std::logic_error)
|
||||
= 0;
|
||||
|
||||
/**
|
||||
* Execute any calls when the daemon is starting up.
|
||||
* All resources allocated here should be freed up in shutdown().
|
||||
* This function will only return when the daemon ha stopped
|
||||
* running.
|
||||
*
|
||||
* @see #shutdown
|
||||
*/
|
||||
virtual void
|
||||
startup (void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the name of the XML element this object expects
|
||||
|
@ -371,7 +383,7 @@ class XmlRpcDaemon
|
|||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
*/
|
||||
virtual void
|
||||
void
|
||||
start (void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
|
@ -388,22 +400,27 @@ class XmlRpcDaemon
|
|||
|
||||
/**
|
||||
* Stop the daemon.
|
||||
* This function just sends a signal, which will result in
|
||||
* shutdown() to get called eventually.
|
||||
*
|
||||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
* @see #shutdown
|
||||
*/
|
||||
virtual void
|
||||
void
|
||||
stop (void) throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Shut down the daemon.
|
||||
* This function is public only because the signal handler
|
||||
* needs visibility to this function, which will call it.
|
||||
* A call to stop() will trigger a signal that will call shutdown().
|
||||
*
|
||||
* @exception std::logic_error if the daemon has not
|
||||
* yet been configured.
|
||||
* @see #stop
|
||||
*/
|
||||
void
|
||||
virtual void
|
||||
shutdown (void) throw (std::logic_error);
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/main.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -199,20 +199,26 @@ int main ( int argc,
|
|||
|
||||
daemon->setBackground(!debugMode);
|
||||
|
||||
if (installCommand == argv[optind]) {
|
||||
daemon->install();
|
||||
} else if (startCommand == argv[optind]) {
|
||||
daemon->start();
|
||||
} else if (statusCommand == argv[optind]) {
|
||||
std::cout << "The Scheduler Daemon is "
|
||||
<< (daemon->isRunning() ? "" : "not ")
|
||||
<< "running" << std::endl;
|
||||
} else if (stopCommand == argv[optind]) {
|
||||
daemon->stop();
|
||||
} else if (uninstallCommand == argv[optind]) {
|
||||
daemon->uninstall();
|
||||
} else {
|
||||
printUsage(argv[0], std::cout);
|
||||
try {
|
||||
if (installCommand == argv[optind]) {
|
||||
daemon->install();
|
||||
} else if (startCommand == argv[optind]) {
|
||||
daemon->start();
|
||||
} else if (statusCommand == argv[optind]) {
|
||||
std::cout << "The Scheduler Daemon is "
|
||||
<< (daemon->isRunning() ? "" : "not ")
|
||||
<< "running" << std::endl;
|
||||
} else if (stopCommand == argv[optind]) {
|
||||
daemon->stop();
|
||||
} else if (uninstallCommand == argv[optind]) {
|
||||
daemon->uninstall();
|
||||
} else {
|
||||
printUsage(argv[0], std::cout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << "error executing command " << argv[optind] << std::endl;
|
||||
std::cerr << e.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue