bool TimebaseRemoteStarter::start()

in src/dxapi/native/tickdb/timebase_starter.cpp [111:163]


bool TimebaseRemoteStarter::start(const char *host, const char *dir)
{
    printf("Starting %s @ HOME: %s\n", host, dir);
    DxApiImpl::Uri uri;
    if (!uri.parse(host)) {
        return false;
    }

    // Check URL again
    auto db = TickDbImpl::createFromUrl(host);
    if (NULL != db) {
        delete db;
    }

    string cmd;
    string dxHome = TimebaseRemoteStarter::getDeltixHome();

    format_string(&cmd, "%s/jre/bin/java.exe -server -Ddeltix.home=\"%s\" -Xmx1024M -jar \"%s/bin/runjava.jar\" deltix.qsrv.comm.cat.TomcatCmd -home \"%s\" -port %u",
        dxHome.c_str(), dxHome.c_str(), dxHome.c_str(), dir, uri.port);

    puts(cmd.c_str());

    FILE * f = _popen(cmd.c_str(), "rt");
    if (NULL == f) {
        return false;
    }

    try {
        int64_t remaining = START_TIMEOUT_MS;
        while (remaining > 0) {
            if (isRunning(host)) {
                return true;
            }

            this_thread::sleep_for(chrono::milliseconds(50));
            remaining -= 50;
        }

        if (NULL != f) {
            _pclose(f);
        }
    }

    catch (...) {
        if (NULL != f) {
            _pclose(f);
        }

        throw;
    }

    return false;
}