Files
mtusi2026lab4/scripts/labhook.cs

34 lines
1.1 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
class Program
{
static int Run(string args)
{
string dir = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".."));
var start = new ProcessStartInfo("docker", args)
{
WorkingDirectory = dir,
UseShellExecute = false
};
var process = Process.Start(start);
process.WaitForExit();
return process.ExitCode;
}
static int Main()
{
string name = Path.GetFileName(Environment.GetCommandLineArgs()[0]).ToLowerInvariant();
if (name.Contains("stop"))
{
string id = Environment.GetEnvironmentVariable("TARGET_INSTANCE_ID");
if (id != "api-1" && id != "api-2") return 2;
return Run("compose --env-file .env stop -t 2 " + id);
}
int up = Run("compose --env-file .env up -d --no-recreate --no-build postgres minio api-1 api-2 lb");
if (up != 0) return up;
return Run("compose --env-file .env restart postgres minio api-1 api-2 lb");
}
}