fix bug with dll selecting in create_service_file_dotnet

This commit is contained in:
Hepatica
2024-08-18 08:30:16 +02:00
parent ef3ccfa686
commit 52e612d957
2 changed files with 32 additions and 19 deletions

View File

@@ -45,28 +45,36 @@ public:
file_processing->unzip(filename, this->publish_app_path + app_final_file_path);
check_port_and_increase_if_not_available();//
file_processing->adjust_nginx_configuration_and_reloud(app->get_name(), std::to_string(last_available_port));//
file_processing->create_service_file(this->publish_app_path, app_final_file_path, std::to_string(last_available_port));
if (app->get_target() == "dotnet network")
{
this->dotnet_publish(this->publish_app_path + app_final_file_path, last_available_port);
check_port_and_increase_if_not_available();
file_processing->adjust_nginx_configuration_and_reloud(app->get_name(), std::to_string(last_available_port));//
file_processing->create_service_file_dotnet(this->publish_app_path, app_final_file_path,
std::to_string(last_available_port), true);
//this->dotnet_publish(this->publish_app_path + app_final_file_path, last_available_port);//Test
app->set_url("https://" + app->get_name() + ".almavid.ru/");
app->set_url_on_local_machine("http://localhost:" + std::to_string(last_available_port));
}
if (app->get_target() == "dotnet")
{
this->dotnet_publish(this->publish_app_path + app_final_file_path);
file_processing->create_service_file_dotnet(this->publish_app_path, app_final_file_path,
std::to_string(last_available_port), false);
//this->dotnet_publish(this->publish_app_path + app_final_file_path);//Test
app->set_url("Worker Service");
app->set_url_on_local_machine("Worker Service");
}
file_processing->delete_file(filename);
app->set_url("https://" + app->get_name() + ".almavid.ru/");//
app->set_url_on_local_machine("http://localhost:" + std::to_string(last_available_port));//
app->set_service_name(app_final_file_path);
return "Publish successfully: " + filename;
@@ -125,8 +133,6 @@ public:
file_processing->stop_service_file(app_final_file_path);
//file_processing->stop_and_start_service_file(app_final_file_path);
return "Success";
}

View File

@@ -223,13 +223,16 @@ public:
std::string response_reload = execute_and_log_command(command_stop);
}
void create_service_file(std::string path, std::string name, std::string port)
void create_service_file_dotnet(std::string path, std::string name, std::string port, bool is_asp)
{
logger_.log(INFO, "Start create_service_file");
logger_.log(INFO, "Start create_service_file_dotnet");
std::string dll_file_name = find_file_by_suffix(path + "/" + name, "exe");
std::string dll_file_name = find_file_by_suffix(path, "exe");
size_t pos = dll_file_name.find(".exe");
if (pos != std::string::npos) {
dll_file_name.replace(pos, 4, ".dll");
}
@@ -243,7 +246,7 @@ public:
std::string exec_start_command = "/usr/bin/dotnet /home/danilt2000/SpCloud/" + name + "/" + dll_file_name;
logger_.log(INFO, "ExecStart command: " + exec_start_command);
logger_.log(INFO, "ExecStart create_service_file");
logger_.log(INFO, "ExecStart create_service_file_dotnet");
serviceFile << "[Service]\n";
serviceFile << "ExecStart=" << exec_start_command << "\n";
@@ -251,7 +254,11 @@ public:
serviceFile << "Restart=always\n";
serviceFile << "User=danilt2000\n";
serviceFile << "Environment=ASPNETCORE_URLS=http://0.0.0.0:" + port + "\n";
if (is_asp)
{
serviceFile << "Environment=ASPNETCORE_URLS=http://0.0.0.0:" + port + "\n";
}
serviceFile << "Environment=PATH=/usr/bin\n";
serviceFile << "Environment=NODE_ENV=production\n\n";