added command line parameters for webui port and base directory.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8069 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-03-22 12:29:30 +00:00
parent 21575dd416
commit 0cd3f3868e
3 changed files with 34 additions and 23 deletions

View file

@ -74,29 +74,36 @@ int main(int argc, char **argv)
{
#ifdef ENABLE_WEBUI
std::string docroot;
bool is_portable = false;
#ifdef WINDOWS_SYS
// test for portable version
if (GetFileAttributes(L"portable") != (DWORD) -1) {
is_portable = true;
}
#endif
std::string docroot = "./";
uint16_t httpPort = 0;
resource_api::ApiServerMHD httpd(docroot, 9090);
argstream args(argc, argv);
args >> parameter("webinterface", httpPort, "port", "Enable webinterface on the specified port", false);
args >> parameter("docroot", docroot, "path", "Serve static files from this path.", false);
args >> help();
resource_api::RsControlModule ctrl_mod(argc, argv, httpd.getApiServer().getStateTokenServer(), &httpd.getApiServer());
httpd.getApiServer().addResourceHandler("control", dynamic_cast<resource_api::ResourceRouter*>(&ctrl_mod), &resource_api::RsControlModule::handleRequest);
httpd.start();
while(ctrl_mod.processShouldExit() == false)
if (args.helpRequested())
{
usleep(20*1000);
std::cerr << args.usage() << std::endl;
}
httpd.stop();
return 1;
if(httpPort != 0)
{
resource_api::ApiServerMHD httpd(docroot, httpPort);
resource_api::RsControlModule ctrl_mod(argc, argv, httpd.getApiServer().getStateTokenServer(), &httpd.getApiServer());
httpd.getApiServer().addResourceHandler("control", dynamic_cast<resource_api::ResourceRouter*>(&ctrl_mod), &resource_api::RsControlModule::handleRequest);
httpd.start();
while(ctrl_mod.processShouldExit() == false)
{
usleep(20*1000);
}
httpd.stop();
return 1;
}
#endif
/* Retroshare startup is configured using an RsInit object.