diff --git a/Server/Application.h b/Server/Application.h index d06d95e..7567674 100644 --- a/Server/Application.h +++ b/Server/Application.h @@ -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"); diff --git a/Server/main.cpp b/Server/main.cpp index 02864c2..827d84a 100644 --- a/Server/main.cpp +++ b/Server/main.cpp @@ -61,14 +61,13 @@ int main(int argc, char const *argv[]) { auto application = Singleton::instance("settings.ini"); auto database = Singleton::instance(); - 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(application->ioContext(), boost::asio::ip::tcp::endpoint{address, application->getPort()}); diff --git a/WebApplication/WebApplication.cpp b/WebApplication/WebApplication.cpp index cd307f7..6cf45c3 100644 --- a/WebApplication/WebApplication.cpp +++ b/WebApplication/WebApplication.cpp @@ -17,23 +17,21 @@ WebApplication::WebApplication(uint16_t port, const std::string &documentRoot) { try { std::vector 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("./build", args); - m_sqlConnectionPool = createConnectionPool(m_server->appRoot() + "database.sqlite"); + m_server = std::make_unique(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(*m_sqlConnectionPool), "/auth"); m_server->addResource(std::make_shared(), "/plaintext"); - m_server->addResource(std::make_shared("database.sqlite"), "/db"); + m_server->addResource(std::make_shared(std::format("{}/database.sqlite", documentRoot)), "/db"); m_server->start(); } catch (const std::exception &e) { diff --git a/resources/build.sh b/resources/build.sh index 246a5a3..5b936e3 100755 --- a/resources/build.sh +++ b/resources/build.sh @@ -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