Commit a9dc289d authored by Pavel Vainerman's avatar Pavel Vainerman

(LogServer): добавил функцию check() для проверки нормально ли запущен LogServer

(codegen): сделал перезапуск LogServer-а (если он не работает) по команде SysCommand::Logrotate
parent 9f0bf5d2
...@@ -474,6 +474,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSysCommand( const SystemMessage* ...@@ -474,6 +474,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::preSysCommand( const SystemMessage*
mylog->logFile(fname.c_str(),true); mylog->logFile(fname.c_str(),true);
mylogany &lt;&lt; myname &lt;&lt; "(preSysCommand): ***************** mylog LOG ROTATE *****************" &lt;&lt; endl; mylogany &lt;&lt; myname &lt;&lt; "(preSysCommand): ***************** mylog LOG ROTATE *****************" &lt;&lt; endl;
} }
if( logserv &amp;&amp; !logserv_host.empty() &amp;&amp; logserv_port != 0 )
logserv-&gt;check(true);
} }
break; break;
......
...@@ -42,6 +42,7 @@ TestGen::TestGen() ...@@ -42,6 +42,7 @@ TestGen::TestGen()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void TestGen::step() void TestGen::step()
{ {
#if 0
cout << "strval: " << strval(input2_s) << endl; cout << "strval: " << strval(input2_s) << endl;
cout << "str: " << str(input2_s) << endl; cout << "str: " << str(input2_s) << endl;
cout << "===========" << endl; cout << "===========" << endl;
...@@ -53,7 +54,7 @@ void TestGen::step() ...@@ -53,7 +54,7 @@ void TestGen::step()
int_var++; int_var++;
bool_var ^= true; bool_var ^= true;
cout << vmon << endl; cout << vmon << endl;
#endif
// cout << vmon.pretty_str() << endl; // cout << vmon.pretty_str() << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
ulimit -Sc 1000000 ulimit -Sc 1000000
uniset2-start.sh -f ./test --name TestProc --confile test.xml --ulog-add-levels warn,crit \ uniset2-start.sh -f ./test --name TestProc --confile test.xml --ulog-add-levels warn,crit \
--test-sm-ready-timeout 15000 --test-run-logserver --test-log-add-levels any $* --test-sm-ready-timeout 15000 --test-run-logserver --test-logserver-host 192.192.192.192
#--test-log-add-levels any $*
#info,warn,crit,system,level9 > 1.log #info,warn,crit,system,level9 > 1.log
#--c-filter-field cfilter --c-filter-value test1 --s-filter-field io --s-filter-value 1 #--c-filter-field cfilter --c-filter-value test1 --s-filter-field io --s-filter-value 1
......
...@@ -113,6 +113,8 @@ class LogServer: ...@@ -113,6 +113,8 @@ class LogServer:
return isrunning; return isrunning;
} }
bool check( bool restart_if_fail = true );
void init( const std::string& prefix, xmlNode* cnode = 0 ); void init( const std::string& prefix, xmlNode* cnode = 0 );
static std::string help_print( const std::string& prefix ); static std::string help_print( const std::string& prefix );
......
...@@ -115,6 +115,45 @@ void LogServer::terminate() ...@@ -115,6 +115,45 @@ void LogServer::terminate()
loop.evstop(this); loop.evstop(this);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool LogServer::check( bool restart_if_fail )
{
try
{
// для проверки пробуем открыть соединение..
UTCPSocket s(addr, port);
s.close();
return true;
}
catch(...){}
if( !restart_if_fail )
return false;
if( !sock )
return false;
io.stop();
io.set<LogServer, &LogServer::ioAccept>(this);
io.start(sock->getSocket(), ev::READ);
try
{
UTCPSocket s(addr, port);
s.close();
return true;
}
catch( Poco::Net::NetException& ex )
{
ostringstream err;
err << myname << "(check): socket error:" << ex.message();
if( mylog.is_crit() )
mylog.crit() << err.str() << endl;
}
return false;
}
// -------------------------------------------------------------------------
void LogServer::evprepare( const ev::loop_ref& eloop ) void LogServer::evprepare( const ev::loop_ref& eloop )
{ {
if( sock ) if( sock )
...@@ -146,8 +185,8 @@ void LogServer::evprepare( const ev::loop_ref& eloop ) ...@@ -146,8 +185,8 @@ void LogServer::evprepare( const ev::loop_ref& eloop )
sock->setBlocking(false); sock->setBlocking(false);
io.set<LogServer, &LogServer::ioAccept>(this);
io.set( eloop ); io.set( eloop );
io.set<LogServer, &LogServer::ioAccept>(this);
io.start(sock->getSocket(), ev::READ); io.start(sock->getSocket(), ev::READ);
isrunning = true; isrunning = true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment