services
This commit is contained in:
parent
34e2bd238c
commit
aa476ec88c
@ -78,7 +78,7 @@ server_env::server_env(const std::string& path) : mValid(false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify required variables exist
|
// Verify required variables exist
|
||||||
for (const auto& var : {"SSH_HOST", "SSH_USER", "SSH_PORT"}) {
|
for (const auto& var : {"SSH_HOST", "SSH_USER", "SSH_PORT", "DROPSHELL_DIR"}) {
|
||||||
if (variables.find(var) == variables.end()) {
|
if (variables.find(var) == variables.end()) {
|
||||||
// print the contents of the _server.env file to screen:
|
// print the contents of the _server.env file to screen:
|
||||||
print_file(env_path.string());
|
print_file(env_path.string());
|
||||||
@ -130,4 +130,8 @@ std::string server_env::get_SSH_PORT() {
|
|||||||
return get_variable("SSH_PORT");
|
return get_variable("SSH_PORT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string server_env::get_DROPSHELL_DIR() {
|
||||||
|
return get_variable("DROPSHELL_DIR");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dropshell
|
} // namespace dropshell
|
@ -24,6 +24,8 @@ class server_env {
|
|||||||
std::string get_SSH_USER();
|
std::string get_SSH_USER();
|
||||||
std::string get_SSH_PORT();
|
std::string get_SSH_PORT();
|
||||||
|
|
||||||
|
std::string get_DROPSHELL_DIR();
|
||||||
|
|
||||||
bool is_valid();
|
bool is_valid();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -9,9 +9,25 @@ class server_service {
|
|||||||
public:
|
public:
|
||||||
server_service();
|
server_service();
|
||||||
bool init(const std::string& server_name, const std::string& service_name);
|
bool init(const std::string& server_name, const std::string& service_name);
|
||||||
bool install();
|
|
||||||
bool is_installed();
|
|
||||||
|
|
||||||
|
// install the service over ssh, using the credentials from _server.env (via server_env.hpp), by:
|
||||||
|
// 1. check if the server_name exists, and the service_name refers to a valid template
|
||||||
|
// 2. check if service_name is valid for the server_name
|
||||||
|
// 3. create the service directory on the server at {DROPSHELL_DIR}/{service_name}
|
||||||
|
// 3. copy the template files into that service directory/template (from the templates directory for the specified server, using templates.hpp to identify the path)
|
||||||
|
// 4. copying the {service_name}.env file to the service directory (from the server directory for the specified server)
|
||||||
|
// 5. running the install.sh script on the server, passing the {service_name}.env file as an argument
|
||||||
|
bool install();
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// then run the command, passing the {service_name}.env file as an argument
|
||||||
|
// do a lot of checks, such as:
|
||||||
|
// checking that we can ssh to the server.
|
||||||
|
// checking whether the service directory exists on the server.
|
||||||
|
// checking that the command exists in the service directory.
|
||||||
|
// checking that the command is a valid .sh file.
|
||||||
|
// checking that the {service_name}.env file exists in the service directory.
|
||||||
bool run_command(const std::string& command);
|
bool run_command(const std::string& command);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
24
templates/squashkiwi/status.sh
Normal file
24
templates/squashkiwi/status.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Source common functions
|
||||||
|
source "$(dirname "$0")/_common.sh"
|
||||||
|
|
||||||
|
# Load environment variables
|
||||||
|
load_env "$1" || exit 1
|
||||||
|
|
||||||
|
# check if the service is running
|
||||||
|
if ! docker ps | grep -q "$CONTAINER_NAME"; then
|
||||||
|
echo "Service is not running"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Service is running"
|
||||||
|
|
||||||
|
# curl -s -X GET http://localhost:8080/health | grep -q "OK"
|
||||||
|
if ! curl -s -X GET http://localhost:${HOST_PORT}/health | grep -q "OK"; then
|
||||||
|
echo "Service is not healthy"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Service is healthy"
|
||||||
|
return 0
|
Loading…
x
Reference in New Issue
Block a user