connection now works

This commit is contained in:
jakani24
2024-03-19 21:46:08 +01:00
parent fd20338513
commit 0195bbbe23
29 changed files with 136 additions and 130 deletions

View File

@@ -11,6 +11,7 @@
int start_thread(const std::string& command) {
if (can_run_thread()) {
bool has_run = 0;
std::string out1, out2;
split(command, ';', out1, out2);
log(LOGLEVEL::INFO_NOSEND, "[start_thread()]: command: ", out1, " arguments: ",out2, " call: ",command);
@@ -20,35 +21,41 @@ int start_thread(const std::string& command) {
// Start a new thread with the scanfile function
std::thread t1(action_scanfile, out2);
t1.detach();
has_run = 1;
}
else if (out1 == "scanfolder") {
// Start a new thread with the scanfolder function
log(LOGLEVEL::INFO, "[start_thread()]: starting scanfolder with arguments: ", out2);
std::thread t1(action_scanfolder, out2);
t1.detach();
has_run = 1;
}
else if (out1 == "update_settings") {
// Start a new thread with the update_settings function
log(LOGLEVEL::INFO, "[start_thread()]: starting update_settings with arguments: ", out2);
std::thread t1(action_update_settings);
t1.detach();
has_run = 1;
}
else if (out1 == "update_db") {
// Start a new thread with the update_db function
log(LOGLEVEL::INFO, "[start_thread()]: starting update_db with arguments: ", out2);
std::thread t1(action_update_db);
t1.detach();
has_run = 1;
}
else if (out1 == "update_system") {
// Start a new thread with the update_db function
log(LOGLEVEL::INFO, "[start_thread()]: starting update_system with arguments: ", out2);
std::thread t1(update_system);
t1.detach();
has_run = 1;
}
while (can_run_thread()) {
// Delay a bit to wait until the thread is started
std::this_thread::sleep_for(std::chrono::milliseconds(10));
if (has_run) {
while (can_run_thread()) {
// Delay a bit to wait until the thread is started
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
}
return 0;