version 1.5, 2001/05/18 16:51:33 |
version 1.6, 2001/05/31 16:44:38 |
| |
| |
TSockId SockId; /// connection to the service | TSockId SockId; /// connection to the service |
uint32 Id; /// uint32 to identify the service | uint32 Id; /// uint32 to identify the service |
| string AliasName; /// alias of the service used in the AES and AS to find him (unique per AES) |
string ShortName; /// name of the service in short format ("NS" for example) | string ShortName; /// name of the service in short format ("NS" for example) |
string LongName; /// name of the service in long format ("naming_service") | string LongName; /// name of the service in long format ("naming_service") |
bool Ready; /// true if the service is ready | bool Ready; /// true if the service is ready |
| |
_chdir(oldpath); | _chdir(oldpath); |
| |
nlinfo ("end executing: %s", Command.c_str()); | nlinfo ("end executing: %s", Command.c_str()); |
| |
| |
} | } |
}; | }; |
| |
| class CExecuteServiceThread : public IRunnable |
| { |
| public: |
| string ServiceAlias, ServiceCommand, ServicePath; |
| |
| CExecuteServiceThread (string serviceAlias, string serviceCommand, string servicePath = "") : |
| ServiceCommand(serviceCommand), ServicePath(servicePath), ServiceAlias(serviceAlias) { } |
| |
| void run () |
| { |
| nlinfo ("start service '%s' '%s' in '%s' directory", ServiceAlias.c_str(), ServiceCommand.c_str(), ServicePath.c_str()); |
| |
| char oldpath[256]; |
| if (!ServicePath.empty()) |
| { |
| _getcwd(oldpath,256); |
| _chdir(ServicePath.c_str()); |
| } |
| |
| system (ServiceCommand.c_str()); |
| |
| if (!ServicePath.empty()) |
| _chdir(oldpath); |
| |
| nlinfo ("end service '%s' '%s' in '%s' directory", ServiceAlias.c_str(), ServiceCommand.c_str(), ServicePath.c_str()); |
| } |
| }; |
| |
void executeCommand (string command, bool background) | void executeCommand (string command, bool background) |
{ | { |
| |
{ | { |
CService *s = (CService*) from->appId(); | CService *s = (CService*) from->appId(); |
| |
msgin.serial (s->ShortName, s->LongName); | msgin.serial (s->AliasName, s->ShortName, s->LongName); |
| |
nlinfo ("*:*:%d is identified to be '%s' '%s'", s->Id, s->ShortName.c_str(), s->LongName.c_str()); | nlinfo ("*:*:%d is identified to be '%s' '%s' '%s'", s->Id, s->AliasName.c_str(), s->ShortName.c_str(), s->LongName.c_str()); |
| |
// broadcast the message to the admin service | // broadcast the message to the admin service |
CMessage msgout (CNetManager::getSIDA ("AESAS"), "SID"); | CMessage msgout (CNetManager::getSIDA ("AESAS"), "SID"); |
msgout.serial (s->Id, s->ShortName, s->LongName); | msgout.serial (s->Id, s->AliasName, s->ShortName, s->LongName); |
CNetManager::send ("AESAS", msgout); | CNetManager::send ("AESAS", msgout); |
} | } |
| |
| |
return; | return; |
} | } |
| |
| // give the service alias to the service to forward it back when it will connected to the aes. |
| command += " -n"; |
| command += serviceAlias.c_str(); |
| |
command += " >NUL:"; | command += " >NUL:"; |
| |
IThread *thread = IThread::create (new CExecuteCommandThread (command, path)); | IThread *thread = IThread::create (new CExecuteServiceThread (serviceAlias, command, path)); |
thread->start (); | thread->start (); |
} | } |
| |