1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/*PROTECTED REGION ID(Starter::main.cpp) ENABLED START*/
//=============================================================================
//
// file : main.cpp
//
// description : C++ source for a TANGO device server main.
// The main rule is to initialise (and create) the Tango
// system and to create the DServerClass singleton.
// The main should be the same for every Tango device server.
//
// project : Starter for Tango Administration.
//
// $Author$
//
// Copyright (C) : 2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This file is part of Tango.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Tango. If not, see <http://www.gnu.org/licenses/>.
//
// $Revision$
// $Date$
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <tango/tango.h>
#ifdef _TG_WINDOWS_
//#define USE_SERVICE
#endif
#ifndef _TG_WINDOWS_
# include <signal.h>
#endif
#ifdef USE_SERVICE
#include <StarterService.h>
using namespace std;
#endif
#ifdef _TG_WINDOWS__DBG
#include "Stackwalker.h"
#endif
#include "Logging.h"
int main(int argc,char *argv[])
{
// First time set SIGINT to default to do not block
// signal handling for child processes
//---------------------------------------------------
#ifndef _TG_WINDOWS_
//sigset(SIGINT, SIG_DFL);
struct sigaction sa;
sa.sa_flags = 0;
sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
if (sigaction(SIGINT,&sa, nullptr) == -1)
std::cerr << "Starter main() --> Can't reset default action for SIGINT to SIG_DFL" << std::endl;
#endif
// Check for hostname
//---------------------------------
if (argc>1)
{
char *p;
for (p=argv[1] ; *p ; p++)
if (*p=='.')
*p = '\0'; // Take off extension (eg:.esrf.fr)
}
// Set an automatic retry on database connection
//---------------------------------------------------
Tango::Util::_daemon = true;
Tango::Util::_sleep_between_connect = 5;
#ifdef USE_SERVICE
StarterService service(argv[0]);
int ret;
if ((ret=service.options(argc, argv))<=0)
return ret;
service.run(argc, argv);
return 0;
#else
try
{
// Initialise the device server
//----------------------------------------
Tango::Util *tg = Tango::Util::init(argc,argv);
// Create the device server singleton
// which will create everything
//----------------------------------------
tg->server_init();
TANGO_LOG_INFO << "Ready to accept request" << std::endl;
// Run the endless loop
//----------------------------------------
#ifdef WIN32_DBG
InitAllocCheck(ACOutput_XML);
#endif
tg->server_run();
}
catch (std::bad_alloc&)
{
std::cerr << "Can't allocate memory to store device object !!!" << std::endl;
std::cerr << "Exiting" << std::endl;
}
catch (CORBA::Exception &e)
{
Tango::Except::print_exception(e);
std::cerr << "Received a CORBA_Exception" << std::endl;
std::cerr << "Exiting" << std::endl;
}
Tango::Util::instance()->server_cleanup();
#ifdef WIN32_DBG
DeInitAllocCheck();
#endif
return(0);
#endif
}
/*PROTECTED REGION END*/ // Starter::main.cpp
|