]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MONITOR/alistoragemanager/alistorage.cxx
SM checks if other SM processes are running. ED macros improved a bit.
[u/mrichter/AliRoot.git] / MONITOR / alistoragemanager / alistorage.cxx
CommitLineData
5eb34a26 1#include "AliStorageClientThread.h"
2#include "AliStorageServerThread.h"
3
2614f1cb 4#include <TThread.h>
5eb34a26 5#include <iostream>
5c7e574d 6#include <string.h>
7#include <sstream>
8#include <cstdlib>
5eb34a26 9
10using namespace std;
11
12void *ClientThreadHandle(void*)
13{
14 cout<<"ALICE Storage Manager -- Starting client thread"<<endl;
15 AliStorageClientThread *client = new AliStorageClientThread();
5eb34a26 16 if(client){delete client;}
17 return 0;
18}
19
20void *ServerThreadHandle(void*)
21{
22 cout<<"\nALICE Storage Manager -- Starting server thread"<<endl;
23 AliStorageServerThread *server = new AliStorageServerThread();
5eb34a26 24 if(server){delete server;}
25 return 0;
26}
27
5c7e574d 28bool isStorageRunning()
29{
30 // check if there is events server already running
31 const char *pid = gSystem->GetFromPipe("pidof alistorage").Data();
32 int pidSize = gSystem->GetFromPipe("pidof alistorage").Sizeof();
33 std::string pidOfAll(pid,pidSize);
34 std::stringstream pidStream(pidOfAll);
35 int word_count=0;
36 std::string word;
37 while( pidStream >> word ) ++word_count;
38 if(word_count != 1){return true;}
39 return false;
40}
41
5eb34a26 42int main()
43{
5c7e574d 44 if(isStorageRunning())
45 {
46 std::cout<<"There is other Storage Manager running on this machine.\n Cannot start multiple managers on the same machine. Quitting..."<<std::endl;
47 return 0;
48 }
49
50
5eb34a26 51 TThread *clientThread = new TThread("clientThread", ClientThreadHandle,NULL);
5eb34a26 52 TThread *serverThread = new TThread("serverThread", ServerThreadHandle,NULL);
2614f1cb 53
5eb34a26 54 clientThread->Run();
55 serverThread->Run();
56
57 clientThread->Join();
2614f1cb 58 serverThread->Kill();//if client thread if finished, server thread is killed
5eb34a26 59 return 0;
60}