change db path.
Some checks failed
Deploy / Build (push) Failing after 33s

This commit is contained in:
luocai 2024-11-25 19:46:24 +08:00
parent 239c34dfbe
commit 8d7694c997
4 changed files with 7 additions and 12 deletions

View File

@ -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");

View File

@ -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()});

View File

@ -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) {

View File

@ -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