main.cpp 1.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* @(#)main.cpp ---
 *
 * Author: Nicolas Niclausse
 * Copyright (C) 2014 - Nicolas Niclausse, Inria.
 * Created: 2014/04/25 16:28:19
 */

/* Commentary:
 *
 */

/* Change log:
 *
 */

#include <dtkDistributed/dtkDistributedServerDaemon.h>
17 18
#include <dtkCore>
#include <dtkLog>
19

20
#include <QtCore>
21 22 23

int main(int argc, char **argv)
{
24
    dtkCoreApplication *application = dtkCoreApplication::create(argc, argv);
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
25
    application->setApplicationName("dtkDistributedServer");
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
26
    application->setApplicationVersion("1.6.3");
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
27 28
    application->setOrganizationName("inria");
    application->setOrganizationDomain("fr");
29

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
30 31 32
    QCommandLineParser *parser = application->parser();

    parser->setApplicationDescription("DTK distributed server application.");
33
    QCommandLineOption typeOption("type", QCoreApplication::translate("main", "type of server "), "Oar| Torque| Local");
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
34
    parser->addOption(typeOption);
35 36
    int port = 9999;
    QCommandLineOption portOption("p", QCoreApplication::translate("main", "listen port"), QString::number(port));
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
37
    parser->addOption(portOption);
38

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
39
    application->initialize();
40

41
    if (!parser->isSet(typeOption)) {
42
        qCritical() << "Error, no type set" ;
43 44
        return 1;
    }
45 46

    if (parser->isSet(portOption)) {
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
47
        port = parser->value(portOption).toInt();
48
    }
49 50


51
    std::cout << "Starting dtkDistributedServer" << std::endl; // DO NOT REMOVE THIS
52

53 54
    QSettings settings("inria", "dtk");
    settings.beginGroup("server");
55

56 57
    if (settings.contains("log_level"))
        dtkLogger::instance().setLevel(settings.value("log_level").toString());
58 59

    settings.endGroup();
60 61

    dtkDistributedServerDaemon server(port);
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
62
    server.setManager( parser->value(typeOption));
63 64
    qDebug() << "server started";

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
65
    int status = qApp->exec();
66 67 68

    return status;
}