派生自 development/c++

chenshijun
2018-12-20 7396acaaf172f25c7bf110e930a74cc133c5d342
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
#include <Ice/Ice.h>
#include <basic/rpc/IceRpc.hpp>
#include <thread>
#include <basic/util/app/AppPreference.hpp>
#include "FaceDetectServerI.h"
int main(int argc,char** argv) {
#ifdef DEBUG
    argc = 2;
    const char* home = argv[0];
    const char* iceCfg = "--Ice.Config=./node/servers/FaceDetectServer/config/config";
    argv = new char*[2];
    argv[0] = (char*)home;
    argv[1] = (char*)iceCfg;
#endif
 
    SAVE_APP_ARGS;
    auto ich = Ice::initialize(argc,argv);
 
#ifdef DEBUG
    std::string identity("FaceDetectServer");
    std::string gpuIndex("0");
    std::string adapterName("FaceDetectServerAdapter");
    int threadMax = 10;
#else
    std::string identity =ich->getProperties()->getProperty("user.face.identity");
    std::string gpuIndex =ich->getProperties()->getProperty("user.gpu.index");
    std::string adapterName = ich->getProperties()->getProperty("user.adapter.name");
    int threadMax = atol(ich->getProperties()->getProperty("user.thread.max").c_str());
#endif
    ich->getProperties()->setProperty("Ice.ThreadPool.Server.SizeMax",to_string(threadMax));
    appPref.setLongData("gpu.index",atol(gpuIndex.c_str()));
    appPref.setLongData("thread.max", threadMax);
 
    auto adapter =  ich->createObjectAdapter(adapterName);
    adapter->add(new FaceDetectServerI(), Ice::stringToIdentity(identity));
    adapter->activate();
    ich->waitForShutdown();
 
    return 0;
}