Added prepull.

This commit is contained in:
rony5394
2026-04-27 15:16:24 +02:00
parent 32069f7e9d
commit 7214e26168
7 changed files with 141 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ func Run(Config cfg.Config) {
sshKeyPair := shared.GenerateSSHKeypair();
sshHostPkPem := exchangeKeys(Config, string(sshKeyPair.Public));
go prepullImage(Config);
createStorageContainer(Config, DockerClient, sshKeyPair.Private, sshHostPkPem);
services := getServices(Config);

30
host/prepullImage.go Normal file
View File

@@ -0,0 +1,30 @@
package host
import (
"bytes"
"log/slog"
"net/http"
"os"
cfg "github.com/rony5394/blazena/config"
);
func prepullImage(Config cfg.Config){
rq, err := http.NewRequest("POST", Config.DockerManagerBaseUrl + "/prepull", bytes.NewBufferString("{}"));
if err != nil{
slog.Error("Failed to create request", slog.Any("propagatedError", err), slog.String("note", "not send just create the object"));
os.Exit(1);
}
rq.Header.Set("Authorization", "Bearer "+ token);
rq.Close = true;
rs, err := http.DefaultClient.Do(rq);
if err != nil{
slog.Error("Failed to send http request", slog.Any("propagatedError", err));
os.Exit(1);
}
defer rs.Body.Close();
}

View File

@@ -37,7 +37,9 @@ func scale(Config cfg.Config, serviceId string, up bool)bool{
rq.Header.Set("Authorization", "Bearer "+ token);
rq.Close = true;
rs, err := http.DefaultClient.Do(rq);
defer rs.Body.Close();
if err == nil {
rs.Body.Close();
}
if err != nil{
panic("Failed to send http request"+ err.Error());