scheduler no longer crashes on startup if the database server is not started

yet.
solution for issue #1200, see http://bugs.campware.org/view.php?id=1200
This commit is contained in:
maroy 2005-07-04 10:38:39 +00:00
parent cb07f820bd
commit f75891c532
4 changed files with 31 additions and 24 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.30 $ Version : $Revision: 1.31 $
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 $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -312,11 +312,7 @@ SchedulerDaemon :: install(void) throw (std::exception)
{ {
// TODO: check if we have already been configured // TODO: check if we have already been configured
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance(); Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
try {
sf->install(); sf->install();
} catch (std::exception &e) {
std::cerr << e.what() << std::endl;
}
Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance(); Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance();
plf->install(); plf->install();
} }
@ -332,6 +328,10 @@ SchedulerDaemon :: isInstalled(void) throw (std::exception)
Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance(); Ptr<ScheduleFactory>::Ref sf = ScheduleFactory::getInstance();
Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance(); Ptr<PlayLogFactory>::Ref plf = PlayLogFactory::getInstance();
if (!sf.get() || !plf.get()) {
throw std::logic_error("coudln't initialize factories");
}
return sf->isInstalled() && plf->isInstalled(); return sf->isInstalled() && plf->isInstalled();
} }
@ -347,6 +347,7 @@ SchedulerDaemon :: uninstall(void) throw (std::exception)
try { try {
plf->uninstall(); plf->uninstall();
} catch (std::exception &e) { } catch (std::exception &e) {
// TODO: don't print but throw it instead
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
} }
@ -359,25 +360,29 @@ SchedulerDaemon :: uninstall(void) throw (std::exception)
* Execute daemon startup functions. * Execute daemon startup functions.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SchedulerDaemon :: startup (void) throw () SchedulerDaemon :: startup (void) throw (std::logic_error)
{ {
try {
if (!isInstalled()) { if (!isInstalled()) {
install(); install();
} }
} catch (std::exception &e) {
throw std::logic_error(std::string("database installation problem: ")
+ e.what());
}
try { try {
sessionId = authentication->login(login, password); sessionId = authentication->login(login, password);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
// TODO: mark error throw std::logic_error(std::string("authentication problem: ")
std::cerr << "authentication problem: " << e.what() << std::endl; + e.what());
} }
try { try {
audioPlayer->initialize(); audioPlayer->initialize();
} catch (std::exception &e) { } catch (std::exception &e) {
// TODO: mark error throw std::logic_error(std::string("audio player initialization "
std::cerr << "audio player initialization problem: " << e.what() "problem: ") + e.what());
<< std::endl;
} }
if (!eventScheduler.get()) { if (!eventScheduler.get()) {
Ptr<PlaylistEventContainer>::Ref eventContainer; Ptr<PlaylistEventContainer>::Ref eventContainer;

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.21 $ Version : $Revision: 1.22 $
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 $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -166,8 +166,8 @@ using namespace LiveSupport::PlaylistExecutor;
* xmlRpcDaemon) &gt; * xmlRpcDaemon) &gt;
* </code></pre> * </code></pre>
* *
* @author $Author: fgerlits $ * @author $Author: maroy $
* @version $Revision: 1.21 $ * @version $Revision: 1.22 $
* @see ConnectionManagerFactory * @see ConnectionManagerFactory
* @see AuthenticationClientFactory * @see AuthenticationClientFactory
* @see StorageClientFactory * @see StorageClientFactory
@ -366,10 +366,11 @@ class SchedulerDaemon : public Installable,
* Execute any calls when the daemon is starting up. * Execute any calls when the daemon is starting up.
* All resources allocated here should be freed up in shutdown(). * All resources allocated here should be freed up in shutdown().
* *
* @exception std::logic_error if startup could not succeed.
* @see #shutdown * @see #shutdown
*/ */
virtual void virtual void
startup (void) throw (); startup (void) throw (std::logic_error);
public: public:

View file

@ -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.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/XmlRpcDaemon.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -289,7 +289,7 @@ XmlRpcDaemon :: start (void) throw (std::logic_error)
* Execute any daemon startup calls. * Execute any daemon startup calls.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
XmlRpcDaemon :: startup (void) throw () XmlRpcDaemon :: startup (void) throw (std::logic_error)
{ {
// and now our own XML-RPC methods // and now our own XML-RPC methods
registerXmlRpcFunctions(xmlRpcServer); registerXmlRpcFunctions(xmlRpcServer);

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
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.4 $ * @version $Revision: 1.5 $
*/ */
class XmlRpcDaemon class XmlRpcDaemon
{ {
@ -254,10 +254,11 @@ class XmlRpcDaemon
* This function will only return when the daemon ha stopped * This function will only return when the daemon ha stopped
* running. * running.
* *
* @exception std::logic_error if startup could not succeed.
* @see #shutdown * @see #shutdown
*/ */
virtual void virtual void
startup (void) throw (); startup (void) throw (std::logic_error);
public: public: