xmlrpc.c 1.05 KB
#include <string.h>     /* for memset and stuff */
#include <syslog.h>     /* for logging */

#include "include/server.h"
#include "include/monitor.h"
#include "include/signalHandling.h"
#include "include/appConfig.h"
#include "include/daemonize.h"

int verbose;


int main(int argc, char *argv[])
{
    tServer server;

    tAppConfig appConfig = {
        0,
        0,
        MAXPENDING,
        DEFAULTPORT,
        DEFAULTPATH,
        LOGNAMEPATTERN
    };

    memset(&server, 0, sizeof(server));

    handleCmdLine(&appConfig, argc, argv);
    verbose = appConfig.verbose;

    /* decouple procss from controlling shell and make it session leader */
    if (appConfig.doDaemon) {
        daemonize();
    }
    init_signals();
    openlog(argv[0], LOG_PID, LOG_USER);

    syslogMonitor(LOG_INFO, MON_INFO, "startup", "service started");

    serverInit(
            &server,
            appConfig.port,
            appConfig.maxPending,
            appConfig.logPath,
            appConfig.namePat);
    serverRun(&server);
    serverShutdown(&server);

    return 0;
}