feat/fix: Show exited containers on UI & better UX

This commit is contained in:
Andras Bacsai
2022-04-20 22:24:41 +02:00
parent a4d56fd79a
commit fbc81ab3eb
9 changed files with 356 additions and 268 deletions

View File

@@ -1,7 +1,7 @@
import { getUserDetails } from '$lib/common';
import * as db from '$lib/database';
import { ErrorHandler } from '$lib/database';
import { checkContainer } from '$lib/haproxy';
import { checkContainer, isContainerExited } from '$lib/haproxy';
import type { RequestHandler } from '@sveltejs/kit';
import jsonwebtoken from 'jsonwebtoken';
import { get as getRequest } from '$lib/api';
@@ -15,17 +15,20 @@ export const get: RequestHandler = async (event) => {
const appId = process.env['COOLIFY_APP_ID'];
let isRunning = false;
let isExited = false;
let githubToken = event.locals.cookies?.githubToken || null;
let gitlabToken = event.locals.cookies?.gitlabToken || null;
try {
const application = await db.getApplication({ id, teamId });
if (application.destinationDockerId) {
isRunning = await checkContainer(application.destinationDocker.engine, id);
isExited = await isContainerExited(application.destinationDocker.engine, id);
}
return {
status: 200,
body: {
isRunning,
isExited,
application,
appId,
githubToken,
@@ -57,11 +60,14 @@ export const post: RequestHandler = async (event) => {
pythonWSGI,
pythonModule,
pythonVariable,
dockerFileLocation
dockerFileLocation,
denoMainFile,
denoOptions
} = await event.request.json();
if (port) port = Number(port);
try {
console.log(buildPack);
const defaultConfiguration = await setDefaultConfiguration({
buildPack,
port,
@@ -70,7 +76,8 @@ export const post: RequestHandler = async (event) => {
buildCommand,
publishDirectory,
baseDirectory,
dockerFileLocation
dockerFileLocation,
denoMainFile
});
await db.configureApplication({
id,
@@ -87,6 +94,8 @@ export const post: RequestHandler = async (event) => {
pythonModule,
pythonVariable,
dockerFileLocation,
denoMainFile,
denoOptions,
...defaultConfiguration
});
return { status: 201 };