mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Goahead demo ok.
This commit is contained in:
parent
20be0d73ed
commit
b3b4e80931
|
@ -25,7 +25,7 @@ TEST(WebServerTest, Demo)
|
|||
CreateLogModule();
|
||||
ILogInit(LOG_INSTANCE_TYPE_END);
|
||||
WebServerInit();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000 * 10));
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(1000 * 10));
|
||||
ILogUnInit();
|
||||
}
|
||||
} // namespace WebServerTest
|
|
@ -13,11 +13,33 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "WebServer.h"
|
||||
#include "ILog.h"
|
||||
#include "goahead.h"
|
||||
#include "js.h"
|
||||
#include <signal.h>
|
||||
static int finished = 0;
|
||||
static void sigHandler(int signo) { finished = 1; }
|
||||
static void sigHandler(int signo)
|
||||
{
|
||||
LogInfo("Stop goahead web server.\n");
|
||||
finished = 1;
|
||||
}
|
||||
static void logHeader(void)
|
||||
{
|
||||
char home[ME_GOAHEAD_LIMIT_STRING];
|
||||
|
||||
getcwd(home, sizeof(home));
|
||||
logmsg(2, "Configuration for %s", ME_TITLE);
|
||||
logmsg(2, "---------------------------------------------");
|
||||
logmsg(2, "Version: %s", ME_VERSION);
|
||||
logmsg(2, "BuildType: %s", ME_DEBUG ? "Debug" : "Release");
|
||||
logmsg(2, "CPU: %s", ME_CPU);
|
||||
logmsg(2, "OS: %s", ME_OS);
|
||||
logmsg(2, "Host: %s", websGetServer());
|
||||
logmsg(2, "Directory: %s", home);
|
||||
logmsg(2, "Documents: %s", websGetDocuments());
|
||||
logmsg(2, "Configure: %s", ME_CONFIG_CMD);
|
||||
logmsg(2, "---------------------------------------------");
|
||||
}
|
||||
void initPlatform(void)
|
||||
{
|
||||
signal(SIGINT, sigHandler);
|
||||
|
@ -28,13 +50,30 @@ void initPlatform(void)
|
|||
|
||||
StatusCode WebServerInit(void)
|
||||
{
|
||||
websSetDebug(1);
|
||||
logSetPath("stdout:2");
|
||||
const char *documents = ME_GOAHEAD_DOCUMENTS;
|
||||
const char *route = "route.txt";
|
||||
const char *route =
|
||||
"/home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/external/goahead-5.2.0/GoAhead/test/route.txt";
|
||||
// /home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/external/goahead-5.2.0/GoAhead/test/route.txt
|
||||
const char *auth =
|
||||
"/home/xiaojiazhu/project/rkipc/battery/ipc-rk1106/ipc-sdk/external/goahead-5.2.0/GoAhead/test/auth.txt";
|
||||
initPlatform();
|
||||
if (websOpen(documents, route) < 0) {
|
||||
error("Cannot initialize server. Exiting.");
|
||||
LogError("Cannot initialize server. Exiting.\n");
|
||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||
}
|
||||
logHeader();
|
||||
if (websLoad(auth) < 0) {
|
||||
LogError("Cannot load %s", auth);
|
||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||
}
|
||||
if (websListen("192.168.1.189:8080") < 0) {
|
||||
return CreateStatusCode(STATUS_CODE_NOT_OK);
|
||||
}
|
||||
websServiceEvents(&finished);
|
||||
logmsg(1, "Instructed to exit\n");
|
||||
websClose();
|
||||
return CreateStatusCode(STATUS_CODE_OK);
|
||||
}
|
||||
StatusCode WebServerUnInit(void) { return CreateStatusCode(STATUS_CODE_OK); }
|
Loading…
Reference in New Issue
Block a user