mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-13 18:05:31 +02:00
feat: add reload, stop and start in remote server
This commit is contained in:
@@ -5,7 +5,7 @@ import { APPLICATIONS_PATH, docker } from "@/server/constants";
|
||||
import type { ContainerInfo, ResourceRequirements } from "dockerode";
|
||||
import { parse } from "dotenv";
|
||||
import type { ApplicationNested } from "../builders";
|
||||
import { execAsync } from "../process/execAsync";
|
||||
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
||||
import { getRemoteDocker } from "../servers/remote-docker";
|
||||
|
||||
interface RegistryAuth {
|
||||
@@ -116,6 +116,15 @@ export const stopService = async (appName: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const stopServiceRemote = async (serverId: string, appName: string) => {
|
||||
try {
|
||||
await execAsyncRemote(serverId, `docker service scale ${appName}=0 `);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
export const getContainerByName = (name: string): Promise<ContainerInfo> => {
|
||||
const opts = {
|
||||
limit: 1,
|
||||
@@ -196,6 +205,15 @@ export const startService = async (appName: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const startServiceRemote = async (serverId: string, appName: string) => {
|
||||
try {
|
||||
await execAsyncRemote(serverId, `docker service scale ${appName}=1 `);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const removeService = async (appName: string) => {
|
||||
try {
|
||||
await execAsync(`docker service rm ${appName}`);
|
||||
|
||||
@@ -145,6 +145,19 @@ export const writeConfig = (appName: string, traefikConfig: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const writeConfigRemote = async (
|
||||
serverId: string,
|
||||
appName: string,
|
||||
traefikConfig: string,
|
||||
) => {
|
||||
try {
|
||||
const configPath = path.join(DYNAMIC_TRAEFIK_PATH, `${appName}.yml`);
|
||||
await execAsyncRemote(serverId, `echo '${traefikConfig}' > ${configPath}`);
|
||||
} catch (e) {
|
||||
console.error("Error saving the YAML config file:", e);
|
||||
}
|
||||
};
|
||||
|
||||
export const writeTraefikConfigInPath = (
|
||||
pathFile: string,
|
||||
traefikConfig: string,
|
||||
|
||||
Reference in New Issue
Block a user