fix: docker compose 실행 시 -f와 --project-directory 옵션 사용
- -f: 컨테이너 내부 경로로 compose 파일 지정 - --project-directory: 호스트 경로로 volumes 해석 - cwd 대신 명시적 경로 지정으로 ENOENT 에러 해결
This commit is contained in:
parent
210740f278
commit
2c15101ad8
1 changed files with 17 additions and 12 deletions
|
|
@ -1178,10 +1178,11 @@ async function getRunningServer() {
|
||||||
// 컨테이너 상태 확인
|
// 컨테이너 상태 확인
|
||||||
async function getContainerStatus(serverPath) {
|
async function getContainerStatus(serverPath) {
|
||||||
try {
|
try {
|
||||||
|
const fullPath = path.join(SERVER_BASE_PATH, serverPath);
|
||||||
const hostPath = path.join(HOST_SERVER_PATH, serverPath);
|
const hostPath = path.join(HOST_SERVER_PATH, serverPath);
|
||||||
|
const composeFile = path.join(fullPath, "docker-compose.yml");
|
||||||
const { stdout } = await execAsync(
|
const { stdout } = await execAsync(
|
||||||
`docker compose ps --format json 2>/dev/null`,
|
`docker compose -f "${composeFile}" --project-directory "${hostPath}" ps --format json 2>/dev/null`
|
||||||
{ cwd: hostPath }
|
|
||||||
);
|
);
|
||||||
if (stdout.trim()) {
|
if (stdout.trim()) {
|
||||||
const containers = stdout
|
const containers = stdout
|
||||||
|
|
@ -1260,11 +1261,14 @@ router.post("/servers/start", async (req, res) => {
|
||||||
|
|
||||||
console.log(`[Admin] 서버 시작 중: ${serverPath}`);
|
console.log(`[Admin] 서버 시작 중: ${serverPath}`);
|
||||||
|
|
||||||
// docker-compose up -d 실행 (호스트 경로 사용)
|
// docker compose up -d 실행
|
||||||
const { stdout, stderr } = await execAsync("docker compose up -d", {
|
// -f: 컨테이너 내부 경로로 파일 지정
|
||||||
cwd: hostPath,
|
// --project-directory: 호스트 경로로 volumes 해석
|
||||||
timeout: 60000, // 60초 타임아웃
|
const composeFile = path.join(fullPath, "docker-compose.yml");
|
||||||
});
|
const { stdout, stderr } = await execAsync(
|
||||||
|
`docker compose -f "${composeFile}" --project-directory "${hostPath}" up -d`,
|
||||||
|
{ timeout: 60000 }
|
||||||
|
);
|
||||||
|
|
||||||
console.log(`[Admin] 서버 시작 완료: ${serverPath}`);
|
console.log(`[Admin] 서버 시작 완료: ${serverPath}`);
|
||||||
res.json({
|
res.json({
|
||||||
|
|
@ -1302,11 +1306,12 @@ router.post("/servers/stop", async (req, res) => {
|
||||||
|
|
||||||
console.log(`[Admin] 서버 종료 중: ${serverPath}`);
|
console.log(`[Admin] 서버 종료 중: ${serverPath}`);
|
||||||
|
|
||||||
// docker-compose down 실행 (호스트 경로 사용)
|
// docker compose down 실행
|
||||||
const { stdout, stderr } = await execAsync("docker compose down", {
|
const composeFile = path.join(fullPath, "docker-compose.yml");
|
||||||
cwd: hostPath,
|
const { stdout, stderr } = await execAsync(
|
||||||
timeout: 60000, // 60초 타임아웃
|
`docker compose -f "${composeFile}" --project-directory "${hostPath}" down`,
|
||||||
});
|
{ timeout: 60000 }
|
||||||
|
);
|
||||||
|
|
||||||
console.log(`[Admin] 서버 종료 완료: ${serverPath}`);
|
console.log(`[Admin] 서버 종료 완료: ${serverPath}`);
|
||||||
res.json({
|
res.json({
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue