This commit is contained in:
parent
239c34dfbe
commit
8d7694c997
@ -30,7 +30,6 @@ public:
|
||||
BUILD_SETTING(uint16_t, WtPort, 8082);
|
||||
BUILD_SETTING(uint32_t, Threads, std::thread::hardware_concurrency());
|
||||
BUILD_SETTING(std::string, DocumentRoot, ".");
|
||||
BUILD_SETTING(std::string, Sqlte3Path, "database.sqlite");
|
||||
BUILD_SETTING(std::string, HomeAssistantAccessToken, "");
|
||||
BUILD_SETTING(std::string, Live2dModelsRoot, "./live2d");
|
||||
|
||||
|
@ -61,14 +61,13 @@ int main(int argc, char const *argv[]) {
|
||||
auto application = Singleton<Application>::instance<Construct>("settings.ini");
|
||||
|
||||
auto database = Singleton<Database>::instance<Construct>();
|
||||
database->open(application->getSqlte3Path());
|
||||
|
||||
if (!std::filesystem::exists(application->getDocumentRoot())) {
|
||||
LOG(fatal) << "document root: " << application->getDocumentRoot() << " is not exists...";
|
||||
std::exit(102);
|
||||
}
|
||||
BOOST_ASSERT_MSG(!application->getServer().empty(), "server.empty() == true");
|
||||
|
||||
database->open(std::format("{}/database.sqlite", application->getDocumentRoot()));
|
||||
auto address = boost::asio::ip::make_address(application->getServer());
|
||||
auto listener =
|
||||
std::make_shared<Listener>(application->ioContext(), boost::asio::ip::tcp::endpoint{address, application->getPort()});
|
||||
|
@ -17,23 +17,21 @@
|
||||
WebApplication::WebApplication(uint16_t port, const std::string &documentRoot) {
|
||||
try {
|
||||
std::vector<std::string> args;
|
||||
args.push_back(std::format("--docroot={};/resources", documentRoot));
|
||||
args.push_back(std::format("--approot={}/resources", documentRoot));
|
||||
args.push_back(std::format("--docroot={}", documentRoot));
|
||||
args.push_back("--config=resources/wt_config.xml");
|
||||
args.push_back(std::format("--http-listen=127.0.0.1:{}", port));
|
||||
// --docroot=. --no-compression --http-listen 127.0.0.1:8855
|
||||
initializeAuthenticationService();
|
||||
|
||||
m_server = std::make_unique<Wt::WServer>("./build", args);
|
||||
m_sqlConnectionPool = createConnectionPool(m_server->appRoot() + "database.sqlite");
|
||||
m_server = std::make_unique<Wt::WServer>(std::format("{}/resources", documentRoot), args);
|
||||
m_sqlConnectionPool = createConnectionPool(std::format("{}/database.sqlite", documentRoot));
|
||||
|
||||
m_server->addEntryPoint(Wt::EntryPointType::Application,
|
||||
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false), "/hello");
|
||||
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false));
|
||||
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet,
|
||||
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true), "/wt/app.js");
|
||||
m_server->addResource(std::make_shared<AuthenticationResource>(*m_sqlConnectionPool), "/auth");
|
||||
m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext");
|
||||
m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db");
|
||||
m_server->addResource(std::make_shared<DbResource>(std::format("{}/database.sqlite", documentRoot)), "/db");
|
||||
|
||||
m_server->start();
|
||||
} catch (const std::exception &e) {
|
||||
|
@ -25,8 +25,7 @@ function build() {
|
||||
# reset
|
||||
# pkill -9 HttpServer
|
||||
# cp -r /opt/Libraries/wt-4.11.1/share/Wt/* ./build
|
||||
# cp resources/*.css build/resources/
|
||||
# cp resources/*.xml build/
|
||||
# cp resources/* build/resources/
|
||||
|
||||
if [ ! -f "${build_path}/CMakeCache.txt" ]; then
|
||||
cmake_scan
|
||||
|
Loading…
Reference in New Issue
Block a user