better error messages.
This commit is contained in:
parent
d95500f679
commit
71cb39d82e
@ -211,7 +211,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
for (const auto& service_info : servicelist) {
|
for (const auto& service_info : servicelist) {
|
||||||
dropshell::service_runner runner(server_name, service_info.service_name);
|
dropshell::service_runner runner(server_name, service_info.service_name);
|
||||||
if (!runner.isValid) {
|
if (!runner.isValid()) {
|
||||||
std::cerr << "Error: Failed to initialize service" << std::endl;
|
std::cerr << "Error: Failed to initialize service" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ typedef struct ServiceStatus {
|
|||||||
class service_runner {
|
class service_runner {
|
||||||
public:
|
public:
|
||||||
service_runner(const std::string& server_name, const std::string& service_name);
|
service_runner(const std::string& server_name, const std::string& service_name);
|
||||||
bool isValid;
|
bool isValid() const { return mValid; }
|
||||||
|
|
||||||
// run a command over ssh, using the credentials from server.env (via server_env.hpp)
|
// run a command over ssh, using the credentials from server.env (via server_env.hpp)
|
||||||
// first check that the command corresponds to a valid .sh file in the service directory
|
// first check that the command corresponds to a valid .sh file in the service directory
|
||||||
|
@ -67,7 +67,17 @@ ServiceInfo get_service_info(const std::string &server_name, const std::string &
|
|||||||
std::string local_service_env_path = get_local_service_env_path(server_name, service_name);
|
std::string local_service_env_path = get_local_service_env_path(server_name, service_name);
|
||||||
envmanager env(local_service_env_path);
|
envmanager env(local_service_env_path);
|
||||||
if (!env.load()) {
|
if (!env.load()) {
|
||||||
std::cerr << "Error: service.env missing from " << local_service_env_path << std::endl;
|
if (std::filesystem::exists(get_local_service_path(server_name, service_name)))
|
||||||
|
std::cerr << "Error: service malformed - service.env missing from " << local_service_env_path << std::endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
template_info tinfo;
|
||||||
|
get_template_info(service_name, tinfo);
|
||||||
|
std::string template_name = service_name;
|
||||||
|
if (tinfo.local_template_path.empty())
|
||||||
|
template_name = "TEMPLATE";
|
||||||
|
std::cerr << "Error: you need to create that service first, with: dropshell create-service " << server_name << " "<<template_name<<" " << service_name << std::endl;
|
||||||
|
}
|
||||||
return ServiceInfo();
|
return ServiceInfo();
|
||||||
}
|
}
|
||||||
service.template_name = env.get_variable("TEMPLATE");
|
service.template_name = env.get_variable("TEMPLATE");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user