/* This will restart the default server on a new IP:PORT. It will stop listening on the default endpoint on the default server, optionally modify the IP:PORT and resume listening. NOTE: running requests will be unaffected. WARNING: this is demonstration code and has no error checking. */ void maRestartServer(cchar *ip, int port) { MaAppweb *appweb; MaServer *server; HttpEndpoint *endpoint; appweb = MPR->appwebService; server = mprGetFirstItem(appweb->servers); lock(appweb->servers); endpoint = mprGetFirstItem(server->endpoints); httpStopEndpoint(endpoint); /* Alternatively, iterate over all endpoints by Http *http = MPR->httpService; int next; for (ITERATE_ITEMS(http->endpoints, endpoint, next)) { ... } */ if (port) { endpoint->port = port; } if (ip) { endpoint->ip = sclone(ip); } httpStartEndpoint(endpoint); unlock(appweb->servers); }
void maStopServer(MaServer *server) { HttpEndpoint *endpoint; int next; for (next = 0; (endpoint = mprGetNextItem(server->endpoints, &next)) != 0; ) { httpStopEndpoint(endpoint); } }
void httpSetEndpointAddress(HttpEndpoint *endpoint, cchar *ip, int port) { if (ip) { endpoint->ip = sclone(ip); } if (port >= 0) { endpoint->port = port; } if (endpoint->sock) { httpStopEndpoint(endpoint); httpStartEndpoint(endpoint); } }
PUBLIC void httpStopEndpoints() { HttpEndpoint *endpoint; Http *http; int next; if ((http = HTTP) == 0) { return; } lock(http->connections); for (next = 0; (endpoint = mprGetNextItem(http->endpoints, &next)) != 0; ) { httpStopEndpoint(endpoint); } unlock(http->connections); }
static void restart() { MaAppweb *appweb; MaServer *server; HttpEndpoint *endpoint; render("Restarting"); flush(); finalize(); appweb = MPR->appwebService; server = mprGetFirstItem(appweb->servers); endpoint = mprGetFirstItem(server->endpoints); httpStopEndpoint(endpoint); endpoint->port = 5555; httpStartEndpoint(endpoint); print("RESTARTING ON PORT 5555"); }
/* This will restart the default server on a new IP:PORT. It will stop listening on the default endpoint on the default server, optionally modify the IP:PORT and resume listening. NOTE: running requests will be unaffected. WARNING: this is demonstration code and has no error checking. */ PUBLIC void maRestartServer(cchar *ip, int port) { MaAppweb *appweb; MaServer *server; HttpEndpoint *endpoint; appweb = MPR->appwebService; server = mprGetFirstItem(appweb->servers); lock(appweb->servers); endpoint = mprGetFirstItem(server->endpoints); httpStopEndpoint(endpoint); if (port) { endpoint->port = port; } if (ip) { endpoint->ip = sclone(ip); } httpStartEndpoint(endpoint); unlock(appweb->servers); }