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 $
|
# 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 $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||||
#
|
#
|
||||||
# @configure_input@
|
# @configure_input@
|
||||||
|
@ -265,6 +265,7 @@ start: ${SCHEDULER_EXE}
|
||||||
|
|
||||||
stop: ${SCHEDULER_EXE}
|
stop: ${SCHEDULER_EXE}
|
||||||
${SCHEDULER_EXE} -c ${SCHEDULER_CFG} stop
|
${SCHEDULER_EXE} -c ${SCHEDULER_CFG} stop
|
||||||
|
sleep 2
|
||||||
|
|
||||||
status: ${SCHEDULER_EXE}
|
status: ${SCHEDULER_EXE}
|
||||||
${SCHEDULER_EXE} -c ${SCHEDULER_CFG} status
|
${SCHEDULER_EXE} -c ${SCHEDULER_CFG} status
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
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(),
|
sf->getSchedule(),
|
||||||
audioPlayer));
|
audioPlayer));
|
||||||
// TODO: read granularity from config file
|
// TODO: read granularity from config file
|
||||||
granularity.reset(new time_duration(seconds(30)));
|
granularity.reset(new time_duration(seconds(1)));
|
||||||
|
|
||||||
eventScheduler.reset(
|
eventScheduler.reset(
|
||||||
new LiveSupport::EventScheduler::EventScheduler(eventContainer,
|
new LiveSupport::EventScheduler::EventScheduler(eventContainer,
|
||||||
|
@ -239,27 +239,27 @@ SchedulerDaemon :: uninstall(void) throw (std::exception)
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Start the scheduler daemon.
|
* Execute daemon startup functions.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
SchedulerDaemon :: start(void) throw (std::logic_error)
|
SchedulerDaemon :: startup (void) throw ()
|
||||||
{
|
{
|
||||||
XmlRpcDaemon::start();
|
|
||||||
audioPlayer->initialize();
|
audioPlayer->initialize();
|
||||||
eventScheduler->start();
|
eventScheduler->start();
|
||||||
|
XmlRpcDaemon::startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Stop the scheduler daemon.
|
* Shut down the daemon
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
SchedulerDaemon :: stop(void) throw (std::logic_error)
|
SchedulerDaemon :: shutdown(void) throw (std::logic_error)
|
||||||
{
|
{
|
||||||
eventScheduler->stop();
|
eventScheduler->stop();
|
||||||
audioPlayer->deInitialize();
|
audioPlayer->deInitialize();
|
||||||
|
|
||||||
XmlRpcDaemon::stop();
|
XmlRpcDaemon::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SchedulerDaemon.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -124,7 +124,7 @@ using namespace LiveSupport::PlaylistExecutor;
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.7 $
|
* @version $Revision: 1.8 $
|
||||||
* @see ConnectionManagerFactory
|
* @see ConnectionManagerFactory
|
||||||
* @see StorageClientFactory
|
* @see StorageClientFactory
|
||||||
* @see ScheduleFactory
|
* @see ScheduleFactory
|
||||||
|
@ -191,6 +191,16 @@ class SchedulerDaemon : public Installable,
|
||||||
registerXmlRpcFunctions(Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
registerXmlRpcFunctions(Ptr<XmlRpc::XmlRpcServer>::Ref xmlRpcServer)
|
||||||
throw (std::logic_error);
|
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:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -246,23 +256,16 @@ class SchedulerDaemon : public Installable,
|
||||||
uninstall(void) throw (std::exception);
|
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
|
* @exception std::logic_error if the daemon has not
|
||||||
* yet been configured.
|
* yet been configured.
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
start (void) throw (std::logic_error);
|
shutdown (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);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SignalDispatcher.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -131,12 +131,17 @@ SignalDispatcher :: removeHandler(
|
||||||
::signal(signal, SIG_DFL);
|
::signal(signal, SIG_DFL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Our signal dispatcher
|
* Our signal dispatcher
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
SignalDispatcher :: dispatcher(int signal) throw ()
|
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);
|
handlers[signal]->handleSignal(signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
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(SIGHUP, handler);
|
||||||
signalDispatcher->registerHandler(SIGTERM, handler);
|
signalDispatcher->registerHandler(SIGTERM, handler);
|
||||||
// FIXME: this signal handler will not be deleted by anyone,
|
// FIXME: this signal handler will not be deleted by anyone,
|
||||||
// poddible memory leak
|
// possible memory leak
|
||||||
|
|
||||||
return true;
|
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
|
// and now our own XML-RPC methods
|
||||||
registerXmlRpcFunctions(xmlRpcServer);
|
registerXmlRpcFunctions(xmlRpcServer);
|
||||||
|
|
||||||
|
@ -322,7 +332,9 @@ XmlRpcDaemon :: stop (void) throw (std::logic_error)
|
||||||
checkForConfiguration();
|
checkForConfiguration();
|
||||||
|
|
||||||
pid_t pid = loadPid();
|
pid_t pid = loadPid();
|
||||||
kill(pid, SIGTERM);
|
if (pid) {
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
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 $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
class XmlRpcDaemon
|
class XmlRpcDaemon
|
||||||
{
|
{
|
||||||
|
@ -248,6 +248,18 @@ class XmlRpcDaemon
|
||||||
throw (std::logic_error)
|
throw (std::logic_error)
|
||||||
= 0;
|
= 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:
|
public:
|
||||||
/**
|
/**
|
||||||
* Return the name of the XML element this object expects
|
* 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
|
* @exception std::logic_error if the daemon has not
|
||||||
* yet been configured.
|
* yet been configured.
|
||||||
*/
|
*/
|
||||||
virtual void
|
void
|
||||||
start (void) throw (std::logic_error);
|
start (void) throw (std::logic_error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -388,22 +400,27 @@ class XmlRpcDaemon
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the daemon.
|
* 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
|
* @exception std::logic_error if the daemon has not
|
||||||
* yet been configured.
|
* yet been configured.
|
||||||
|
* @see #shutdown
|
||||||
*/
|
*/
|
||||||
virtual void
|
void
|
||||||
stop (void) throw (std::logic_error);
|
stop (void) throw (std::logic_error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shut down the daemon.
|
* Shut down the daemon.
|
||||||
* This function is public only because the signal handler
|
* This function is public only because the signal handler
|
||||||
* needs visibility to this function, which will call it.
|
* 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
|
* @exception std::logic_error if the daemon has not
|
||||||
* yet been configured.
|
* yet been configured.
|
||||||
|
* @see #stop
|
||||||
*/
|
*/
|
||||||
void
|
virtual void
|
||||||
shutdown (void) throw (std::logic_error);
|
shutdown (void) throw (std::logic_error);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
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 $
|
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);
|
daemon->setBackground(!debugMode);
|
||||||
|
|
||||||
if (installCommand == argv[optind]) {
|
try {
|
||||||
daemon->install();
|
if (installCommand == argv[optind]) {
|
||||||
} else if (startCommand == argv[optind]) {
|
daemon->install();
|
||||||
daemon->start();
|
} else if (startCommand == argv[optind]) {
|
||||||
} else if (statusCommand == argv[optind]) {
|
daemon->start();
|
||||||
std::cout << "The Scheduler Daemon is "
|
} else if (statusCommand == argv[optind]) {
|
||||||
<< (daemon->isRunning() ? "" : "not ")
|
std::cout << "The Scheduler Daemon is "
|
||||||
<< "running" << std::endl;
|
<< (daemon->isRunning() ? "" : "not ")
|
||||||
} else if (stopCommand == argv[optind]) {
|
<< "running" << std::endl;
|
||||||
daemon->stop();
|
} else if (stopCommand == argv[optind]) {
|
||||||
} else if (uninstallCommand == argv[optind]) {
|
daemon->stop();
|
||||||
daemon->uninstall();
|
} else if (uninstallCommand == argv[optind]) {
|
||||||
} else {
|
daemon->uninstall();
|
||||||
printUsage(argv[0], std::cout);
|
} 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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue