Project

General

Profile

Rendering template within a template on the server-side. » main.cpp

Plug Gulp, 03/04/2019 12:27 AM

 

#include <cstdlib>

#include <signal.h>

#include <Wt/WServer.h>

#include "start.hpp"

extern char **environ; // POSIX defined

int main(int argc, char **argv)
{
auto r = EXIT_FAILURE;

try {
// Initialise a web server.
Wt::WServer server{argc, argv};

// Load the web app user interface.
auto bundle = std::make_shared<Wt::WMessageResourceBundle>();
bundle->use(server.appRoot() + "web_ui");
server.setLocalizedStrings(bundle);

// Mount the web app request handler.
start _start;
server.addResource(&_start, "/");

// Start the server and handle shutdown.
if(server.start()) {
int sig = Wt::WServer::waitForShutdown();

server.stop();

if(SIGHUP == sig) {
Wt::WServer::restart(argc, argv, environ);
} else {
r = EXIT_SUCCESS;
}
}
} catch(Wt::WException const &e) {
std::cerr << "Wt Exception: " << e.what() << std::endl;
} catch(std::exception const &e) {
std::cerr << "Standard Exception: " << e.what() << std::endl;
}

return r;
}

(2-2/3)