#include <Ice/Ice.h>
|
#include <basic/rpc/IceRpc.hpp>
|
#include <thread>
|
#include <basic/util/app/AppPreference.hpp>
|
#include "FaceDetectServerI.h"
|
#include <basic/debug/Debug.h>
|
#include <basic/util/app/AppConfig.h>
|
|
int main1(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", std::to_string(threadMax));
|
appPref.setIntData("gpu.index", atol(gpuIndex.c_str()));
|
appPref.setIntData("thread.max", threadMax);
|
|
auto adapter = ich->createObjectAdapter(adapterName);
|
adapter->add(new FaceDetectServerI(), Ice::stringToIdentity(identity));
|
adapter->activate();
|
ich->waitForShutdown();
|
|
return 0;
|
}
|
|
int main(int argc, char **argv) {
|
SAVE_APP_ARGS;
|
ENABLEGLOG(GET_STR_CONFIG("logPath").c_str());
|
auto ich = Ice::initialize(argc, argv);
|
|
if (argc < 4) {
|
assert("t_value.size()");
|
}
|
appPref.setIntData("gpu.index", atoi(argv[1]));
|
appPref.setIntData("RpcFDPort", atoi(argv[2]));
|
appPref.setIntData("thread.max", atoi(argv[3]));//线程池大小
|
|
IceRpcServer<FaceDetectServerI> server("faceServer", appPref.getIntData("RpcFDPort"), "tcp");
|
server.setMessageSizeMax(1024 * 1024 * 50);
|
server.setPoolInitSize(appPref.getIntData("thread.max"));
|
DBG("MaxPoolSize: " << std::max(appPref.getIntData("thread.max")*2, 32));
|
server.setPoolMaxSize(std::max(appPref.getIntData("thread.max")*2, 32));
|
server.runWaitShutDown();
|
return 0;
|
}
|