Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: Database and services logs

Andras Bacsai8e42203b897a
diff --git a/src/lib/components/svg/databases/Redis.svelte b/src/lib/components/svg/databases/Redis.svelte
index 2571e601da..24a7dc7973 100644
--- a/src/lib/components/svg/databases/Redis.svelte
+++ b/src/lib/components/svg/databases/Redis.svelte
@@ -4,9 +4,7 @@
<svg
class={isAbsolute ? 'absolute top-0 left-0 -m-5 h-10 w-10' : 'mx-auto w-8 h-8'}
- height="64"
viewBox="0 0 32 32"
- width="64"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
><defs
diff --git a/src/lib/components/svg/services/Fider.svelte b/src/lib/components/svg/services/Fider.svelte
new file mode 100644
index 0000000000..6d7ccaba7e
--- /dev/null
+++ b/src/lib/components/svg/services/Fider.svelte
@@ -0,0 +1,121 @@
+<script lang="ts">
+ export let isAbsolute = false;
+</script>
+
+<svg
+ viewBox="0 0 700 240"
+ xmlns="http://www.w3.org/2000/svg"
+ class={isAbsolute ? 'w-36 absolute top-0 left-0 -m-3 -mt-5' : 'w-28 mx-auto'}
+ ><path fill="#FDBC3D" d="m90.694 107.498-.981.39-20.608 8.23 6.332 6.547z" /><path
+ fill="#8EC63F"
+ d="M61.139 77.914 46.632 93 56.9 103.547c8.649-7.169 17.832-10.502 18.653-10.789L61.139 77.914z"
+ /><path fill="#208ECB" d="M61.139 77.914 46.367 63.247l-14.228 14.8 14.493 14.952z" /><path
+ fill="#273C8B"
+ d="m40.767 57.48-6.943 2.79a38.381 38.381 0 0 0-11.742 7.418L32.14 78.047l14.228-14.8-5.601-5.768z"
+ /><path
+ fill="#EE4649"
+ d="m119.074 138.128-.243-.25-5.653 5.675c1.897-1.516 4.287-3.66 5.896-5.425z"
+ /><path
+ fill="#F6944E"
+ d="m102.088 150.087 3.709-1.875a46.26 46.26 0 0 0 7.381-4.659l5.653-5.676-14.311-15.285-14.493 15.072 12.061 12.423z"
+ /><path fill="#FFC951" d="m90.279 107.926-14.842 14.74 14.589 14.998 14.493-15.072z" /><path
+ fill="#F6CC18"
+ d="m69.087 116.125-11.256 4.493c-3.301.973-6.096 2.843-8.434 5.081l11.548 11.892 14.493-14.926-6.35-6.54z"
+ /><path
+ fill="#C5D82D"
+ d="m56.886 103.559-10.253-10.56L32 107.926l11.784 11.991c3.304-6.888 8.174-12.272 13.103-16.358z"
+ /><path fill="#0D77B3" d="m32.14 78.047-14.507 14.94 14.365 14.939 14.634-14.927z" /><path
+ fill="#2A377E"
+ d="M32.14 78.047 22.08 67.688a38.573 38.573 0 0 0-11.093 18.455l6.645 6.843 14.506-14.94z"
+ /><path
+ fill="#DA2128"
+ d="m94.826 162.454-4.87 5.017 14.808 15.397c-.632-1.942-1.606-4.438-2.58-6.307l-7.357-14.107z"
+ /><path
+ fill="#F8A561"
+ d="m91.24 155.575 10.832-5.48-12.046-12.43-14.506 14.939 14.436 14.867 4.87-5.017z"
+ /><path fill="#FDBC3D" d="m75.437 122.665-14.493 14.926 14.576 15.013 14.506-14.94z" /><path
+ fill="#FAD412"
+ d="M49.397 125.7c-6.71 6.472-9.664 16.047-9.664 16.047-.3-4.606.06-8.83.907-12.698l-8.513 8.742 14.311 14.74 14.506-14.94-11.547-11.892z"
+ /><path
+ fill="#C4D52D"
+ d="m43.783 119.917-11.785-11.991-13.29 13.687 3.708 6.178 9.71 10 8.52-8.775a42.699 42.699 0 0 1 3.137-9.099z"
+ /><path
+ fill="#1B80C1"
+ d="m17.633 92.986-7.638 7.72c.65 5.1 2.35 10.3 5.193 15.04l3.52 5.867 13.29-13.687-14.365-14.94z"
+ /><path
+ fill="#1A4685"
+ d="M10.989 86.143c-1.22 4.667-1.597 9.683-.993 14.563l7.638-7.72-6.645-6.843z"
+ /><path
+ fill="#B12026"
+ d="m89.956 197.35 12.502 13.022c4.143-8.355 5.148-18.255 2.307-27.504l-.302-.311-14.507 14.793z"
+ /><path fill="#E42028" d="M89.956 167.47 75.52 182.484l14.436 14.867 14.506-14.793z" /><path
+ fill="#F16B4E"
+ d="m75.52 152.604-14.576 14.867 14.576 15.012 14.436-15.012z"
+ /><path fill="#FAD412" d="m60.944 137.591-14.506 14.94 14.506 14.94 14.576-14.867z" /><path
+ fill="#FFC951"
+ d="m32.127 137.792-2.293 2.36 10.933 18.22 5.671-5.841z"
+ /><path fill="#FFC951" d="m22.416 127.79 7.418 12.363 2.293-2.361z" /><path
+ fill="#981C20"
+ d="M102.458 210.371 89.955 197.35 75.45 212.29l12.918 13.304a36.951 36.951 0 0 0 14.09-15.222z"
+ /><path
+ fill="#C92039"
+ d="m75.52 182.483-12.59 12.823 6.423 10.704 6.097 6.28 14.506-14.94z"
+ /><path fill="#F05B41" d="m60.944 167.47-9.096 9.369 11.081 18.467 12.59-12.823z" /><path
+ fill="#F6CC18"
+ d="m46.438 152.53-5.671 5.842 11.081 18.467 9.096-9.368z"
+ /><path
+ fill="#7A1319"
+ d="m74.01 213.772 8.904 14.838 4.104-2.237c.429-.233.934-.533 1.35-.78L75.45 212.29l-1.44 1.482z"
+ /><path fill="#981C20" d="m69.353 206.01 4.658 7.762 1.44-1.482z" /><path
+ fill="#15796E"
+ d="m147.842 48.094 10.653-10.971a41.81 41.81 0 0 0 .943-6.94l-11.414-11.755-14.48 14.94 14.298 14.726z"
+ /><path fill="#29B364" d="m133.53 33.354 14.494-14.926-2.737-2.965-20.95 8.422z" /><path
+ fill="#21A29F"
+ d="M151.819 52.189c3.057-4.334 5.434-9.932 6.677-15.066l-10.653 10.971 3.976 4.095z"
+ /><path
+ fill="#12827F"
+ d="M159.438 30.183c.307-6.28-.783-12.862-3.488-19.006l-1.41.567-6.516 6.684 11.414 11.755zM154.54 11.744l-9.253 3.72 2.737 2.964z"
+ /><path fill="#0C6355" d="m133.336 63.034 14.506-14.94-14.311-14.713-14.493 14.926z" /><path
+ fill="#1B974D"
+ d="m104.532 33.368 14.506 14.94 14.48-14.94-9.2-9.476-17.363 6.98z"
+ /><path fill="#16669F" d="m106.955 30.872-3.485 1.401 1.062 1.095z" /><path
+ fill="#44BFBD"
+ d="M135.9 65.674A41.696 41.696 0 0 0 151.82 52.19l-3.977-4.095-14.506 14.94 2.564 2.64z"
+ /><path
+ fill="#0D5650"
+ d="m115.71 74.76 11.052-4.956 6.574-6.77-14.298-14.727-14.506 14.94z"
+ /><path fill="#3FAF49" d="m119.038 48.307-14.506-14.94-14.576 14.868 14.563 14.999z" /><path
+ fill="#0D77B3"
+ d="m104.532 33.368-1.062-1.095-20.97 8.43 7.456 7.532z"
+ /><path
+ fill="#0C6355"
+ d="M134.766 66.217c.352-.157.789-.376 1.134-.543l-2.564-2.64-6.574 6.77 8.004-3.587z"
+ /><path fill="#12827F" d="m115.71 74.76-11.178-11.513-14.506 14.94 5.47 5.633z" /><path
+ fill="#4EB648"
+ d="M104.532 63.247 89.956 48.235 75.52 63.247l14.493 14.927z"
+ /><path fill="#16669F" d="M89.956 48.235 82.5 40.703l-20.868 8.388L75.52 63.247z" /><path
+ fill="#FBB139"
+ d="M129.526 119.012c1.902-7.144 2.108-15.019.353-22.538l-11.048 11.379 10.695 11.16z"
+ /><path
+ fill="#E2B523"
+ d="m110.62 99.542 8.21 8.311 11.049-11.38a46.303 46.303 0 0 0-1.186-4.149l-18.074 7.218z"
+ /><path fill="#189590" d="M90.026 78.186 76.128 92.501l19.367-8.681z" /><path
+ fill="#8EC63F"
+ d="m76.083 92.521 13.943-14.335-14.506-14.94-14.381 14.668 14.413 14.844z"
+ /><path
+ fill="#0D77B3"
+ d="M75.52 63.247 61.633 49.09l-2.264.91-13.002 13.246L61.14 77.914z"
+ /><path fill="#1953A2" d="m59.37 50.002-18.603 7.477 5.6 5.768z" /><path
+ fill="#ED3551"
+ d="M119.324 137.84c.885-.988 2.15-2.59 2.942-3.646l-3.17 3.41.228.236z"
+ /><path
+ fill="#F8A561"
+ d="m118.83 137.877 3.437-3.683a46.268 46.268 0 0 0 7.259-15.182l-10.695-11.159-14.311 14.74 14.31 15.284z"
+ /><path
+ fill="#E9B520"
+ d="m90.279 107.926 14.24 14.666 14.312-14.739-8.212-8.311-19.925 7.956z"
+ /><path
+ fill="#EE4649"
+ d="m118.83 137.877.244.251c.085-.095.166-.193.25-.288l-.228-.235-.265.272z"
+ /></svg
+>
diff --git a/src/lib/database/common.ts b/src/lib/database/common.ts
index 968208f552..314f77b087 100644
--- a/src/lib/database/common.ts
+++ b/src/lib/database/common.ts
@@ -11,11 +11,12 @@ import generator from 'generate-password';
import forge from 'node-forge';
import getPort, { portNumbers } from 'get-port';
-export function generatePassword(length = 24): string {
+export function generatePassword(length = 24, symbols = false): string {
return generator.generate({
length,
numbers: true,
- strict: true
+ strict: true,
+ symbols
});
}
diff --git a/src/lib/database/services.ts b/src/lib/database/services.ts
index 9e3d1b4677..df760cf767 100644
--- a/src/lib/database/services.ts
+++ b/src/lib/database/services.ts
@@ -15,7 +15,8 @@ const include: Prisma.ServiceInclude = {
ghost: true,
meiliSearch: true,
umami: true,
- hasura: true
+ hasura: true,
+ fider: true
};
export async function listServicesWithIncludes() {
return await prisma.service.findMany({
@@ -103,6 +104,12 @@ export async function getService({ id, teamId }: { id: string; teamId: string })
if (body.hasura?.graphQLAdminPassword)
body.hasura.graphQLAdminPassword = decrypt(body.hasura.graphQLAdminPassword);
+ if (body.fider?.postgresqlPassword)
+ body.fider.postgresqlPassword = decrypt(body.fider.postgresqlPassword);
+ if (body.fider?.jwtSecret) body.fider.jwtSecret = decrypt(body.fider.jwtSecret);
+ if (body.fider?.emailSmtpPassword)
+ body.fider.emailSmtpPassword = decrypt(body.fider.emailSmtpPassword);
+
const settings = await prisma.setting.findFirst();
return { ...body, settings };
@@ -268,6 +275,25 @@ export async function configureServiceType({
}
}
});
+ } else if (type === 'fider') {
+ const postgresqlUser = cuid();
+ const postgresqlPassword = encrypt(generatePassword());
+ const postgresqlDatabase = 'fider';
+ const jwtSecret = encrypt(generatePassword(64, true));
+ await prisma.service.update({
+ where: { id },
+ data: {
+ type,
+ fider: {
+ create: {
+ postgresqlDatabase,
+ postgresqlPassword,
+ postgresqlUser,
+ jwtSecret
+ }
+ }
+ }
+ });
}
}
@@ -326,52 +352,53 @@ export async function updateService({
return await prisma.service.update({ where: { id }, data: { fqdn, name } });
}
-export async function updateLanguageToolService({
- id,
- fqdn,
- name
-}: {
- id: string;
- fqdn: string;
- name: string;
-}): Promise<Service> {
- return await prisma.service.update({ where: { id }, data: { fqdn, name } });
-}
-
-export async function updateMeiliSearchService({
- id,
- fqdn,
- name
-}: {
- id: string;
- fqdn: string;
- name: string;
-}): Promise<Service> {
- return await prisma.service.update({ where: { id }, data: { fqdn, name } });
-}
-
-export async function updateVaultWardenService({
- id,
- fqdn,
- name
-}: {
- id: string;
- fqdn: string;
- name: string;
-}): Promise<Service> {
- return await prisma.service.update({ where: { id }, data: { fqdn, name } });
-}
-
-export async function updateVsCodeServer({
+export async function updateFiderService({
id,
fqdn,
- name
+ name,
+ emailNoreply,
+ emailMailgunApiKey,
+ emailMailgunDomain,
+ emailMailgunRegion,
+ emailSmtpHost,
+ emailSmtpPort,
+ emailSmtpUser,
+ emailSmtpPassword,
+ emailSmtpEnableStartTls
}: {
id: string;
fqdn: string;
name: string;
+ emailNoreply: string;
+ emailMailgunApiKey: string;
+ emailMailgunDomain: string;
+ emailMailgunRegion: string;
+ emailSmtpHost: string;
+ emailSmtpPort: number;
+ emailSmtpUser: string;
+ emailSmtpPassword: string;
+ emailSmtpEnableStartTls: boolean;
}): Promise<Service> {
- return await prisma.service.update({ where: { id }, data: { fqdn, name } });
+ return await prisma.service.update({
+ where: { id },
+ data: {
+ fqdn,
+ name,
+ fider: {
+ update: {
+ emailNoreply,
+ emailMailgunApiKey,
+ emailMailgunDomain,
+ emailMailgunRegion,
+ emailSmtpHost,
+ emailSmtpPort,
+ emailSmtpUser,
+ emailSmtpPassword,
+ emailSmtpEnableStartTls
+ }
+ }
+ }
+ });
}
export async function updateWordpress({
@@ -423,6 +450,7 @@ export async function updateGhostService({
export async function removeService({ id }: { id: string }): Promise<void> {
await prisma.servicePersistentStorage.deleteMany({ where: { serviceId: id } });
await prisma.meiliSearch.deleteMany({ where: { serviceId: id } });
+ await prisma.fider.deleteMany({ where: { serviceId: id } });
await prisma.ghost.deleteMany({ where: { serviceId: id } });
await prisma.umami.deleteMany({ where: { serviceId: id } });
await prisma.hasura.deleteMany({ where: { serviceId: id } });
diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json
index a5d6cbd50f..22c7adf38f 100644
--- a/src/lib/locales/en.json
+++ b/src/lib/locales/en.json
@@ -228,7 +228,8 @@
"permission_denied_start_database": "You do not have permission to start the database.",
"delete_database": "Delete Database",
"permission_denied_delete_database": "You do not have permission to delete a Database",
- "no_databases_found": "No databases found"
+ "no_databases_found": "No databases found",
+ "logs": "Database Logs"
},
"destination": {
"delete_destination": "Delete Destination",
@@ -293,7 +294,8 @@
"permission_denied_start_service": "You do not have permission to start the service.",
"delete_service": "Delete Service",
"permission_denied_delete_service": "You do not have permission to delete a service.",
- "no_service": "No services found"
+ "no_service": "No services found",
+ "logs": "Service Logs"
},
"setting": {
"change_language": "Change Language",
diff --git a/src/routes/applications/[id]/__layout.svelte b/src/routes/applications/[id]/__layout.svelte
index bf634edde5..cc8c19c194 100644
--- a/src/routes/applications/[id]/__layout.svelte
+++ b/src/routes/applications/[id]/__layout.svelte
@@ -394,7 +394,7 @@
>
<div class="border border-coolgray-500 h-8" />
<a
- href={!$disabledButton ? `/applications/${id}/logs` : null}
+ href={!$disabledButton && isRunning ? `/applications/${id}/logs` : null}
sveltekit:prefetch
class="hover:text-sky-500 rounded"
class:text-sky-500={$page.url.pathname === `/applications/${id}/logs`}
@@ -402,7 +402,7 @@
>
<button
title={$t('application.logs')}
- disabled={$disabledButton}
+ disabled={$disabledButton || !isRunning}
class="icons bg-transparent tooltip-bottom text-sm"
data-tooltip={$t('application.logs')}
>
diff --git a/src/routes/applications/[id]/configuration/_GithubRepositories.svelte b/src/routes/applications/[id]/configuration/_GithubRepositories.svelte
index 80a4d246ed..8b5b932cdb 100644
--- a/src/routes/applications/[id]/configuration/_GithubRepositories.svelte
+++ b/src/routes/applications/[id]/configuration/_GithubRepositories.svelte
@@ -185,7 +185,7 @@
? $t('application.configuration.loading_repositories')
: $t('application.configuration.select_a_repository')}
id="repository"
- showIndicator={true}
+ showIndicator={!loading.repositories}
isWaiting={loading.repositories}
on:select={loadBranches}
items={reposSelectOptions}
@@ -202,7 +202,7 @@
? $t('application.configuration.select_a_repository_first')
: $t('application.configuration.select_a_branch')}
isWaiting={loading.branches}
- showIndicator={selected.repository}
+ showIndicator={selected.repository && !loading.branches}
id="branches"
on:select={isBranchAlreadyUsed}
items={branchSelectOptions}
diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte
index 5f801e05be..e9c558706e 100644
--- a/src/routes/applications/[id]/index.svelte
+++ b/src/routes/applications/[id]/index.svelte
@@ -345,6 +345,7 @@
<label for="baseBuildImage" class="text-base font-bold text-stone-100"
>{$t('application.base_build_image')}</label
>
+
<div class="custom-select-wrapper">
<Select
isDisabled={!$session.isAdmin || isRunning}
@@ -357,6 +358,9 @@
isClearable={false}
/>
</div>
+ {#if application.buildPack === 'laravel'}
+ <Explainer text="For building frontend assets with webpack." />
+ {/if}
</div>
{/if}
</div>
diff --git a/src/routes/applications/[id]/logs/index.svelte b/src/routes/applications/[id]/logs/index.svelte
index 81306a71ff..01d4157257 100644
--- a/src/routes/applications/[id]/logs/index.svelte
+++ b/src/routes/applications/[id]/logs/index.svelte
@@ -98,12 +98,12 @@
}
</script>
-<div class="flex items-center space-x-2 p-5 px-6 font-bold">
+<div class="flex items-center space-x-2 p-6 text-2xl font-bold">
<div class="-mb-5 flex-col">
<div class="md:max-w-64 truncate text-base tracking-tight md:text-2xl lg:block">
Application Logs
</div>
- <span class="text-xs">{application.name} </span>
+ <span class="text-xs">{application.name}</span>
</div>
{#if application.fqdn}
diff --git a/src/routes/databases/[id]/__layout.svelte b/src/routes/databases/[id]/__layout.svelte
index 6b62c2cd1e..2696910f7f 100644
--- a/src/routes/databases/[id]/__layout.svelte
+++ b/src/routes/databases/[id]/__layout.svelte
@@ -57,7 +57,7 @@
</script>
<script>
- import { session } from '$app/stores';
+ import { page, session } from '$app/stores';
import { errorNotification } from '$lib/form';
import DeleteIcon from '$lib/components/DeleteIcon.svelte';
import Loading from '$lib/components/Loading.svelte';
@@ -65,6 +65,8 @@
import { goto } from '$app/navigation';
import { t } from '$lib/translations';
+ const { id } = $page.params;
+
export let database;
export let isRunning;
let loading = false;
@@ -163,6 +165,75 @@
</button>
{/if}
{/if}
+ <div class="border border-stone-700 h-8" />
+ <a
+ href="/databases/{id}"
+ sveltekit:prefetch
+ class="hover:text-yellow-500 rounded"
+ class:text-yellow-500={$page.url.pathname === `/databases/${id}`}
+ class:bg-coolgray-500={$page.url.pathname === `/databases/${id}`}
+ >
+ <button
+ title={$t('application.configurations')}
+ class="icons bg-transparent tooltip-bottom text-sm disabled:text-red-500"
+ data-tooltip={$t('application.configurations')}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ class="h-6 w-6"
+ viewBox="0 0 24 24"
+ stroke-width="1.5"
+ stroke="currentColor"
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <rect x="4" y="8" width="4" height="4" />
+ <line x1="6" y1="4" x2="6" y2="8" />
+ <line x1="6" y1="12" x2="6" y2="20" />
+ <rect x="10" y="14" width="4" height="4" />
+ <line x1="12" y1="4" x2="12" y2="14" />
+ <line x1="12" y1="18" x2="12" y2="20" />
+ <rect x="16" y="5" width="4" height="4" />
+ <line x1="18" y1="4" x2="18" y2="5" />
+ <line x1="18" y1="9" x2="18" y2="20" />
+ </svg></button
+ ></a
+ >
+ <div class="border border-stone-700 h-8" />
+ <a
+ href={isRunning ? `/databases/${id}/logs` : null}
+ sveltekit:prefetch
+ class="hover:text-pink-500 rounded"
+ class:text-pink-500={$page.url.pathname === `/databases/${id}/logs`}
+ class:bg-coolgray-500={$page.url.pathname === `/databases/${id}/logs`}
+ >
+ <button
+ title={$t('database.logs')}
+ disabled={!isRunning}
+ class="icons bg-transparent tooltip-bottom text-sm"
+ data-tooltip={$t('database.logs')}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ class="h-6 w-6"
+ viewBox="0 0 24 24"
+ stroke-width="1.5"
+ stroke="currentColor"
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
+ <path d="M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
+ <line x1="3" y1="6" x2="3" y2="19" />
+ <line x1="12" y1="6" x2="12" y2="19" />
+ <line x1="21" y1="6" x2="21" y2="19" />
+ </svg></button
+ ></a
+ >
<button
on:click={deleteDatabase}
title={$t('database.delete_database')}
diff --git a/src/routes/databases/[id]/logs/_Loading.svelte b/src/routes/databases/[id]/logs/_Loading.svelte
new file mode 100644
index 0000000000..73fbe709e9
--- /dev/null
+++ b/src/routes/databases/[id]/logs/_Loading.svelte
@@ -0,0 +1,41 @@
+<div class="lds-ripple absolute left-0">
+ <div />
+ <div />
+</div>
+
+<style>
+ .lds-ripple {
+ display: inline-block;
+ position: relative;
+ left: -19px;
+ top: -8px;
+ width: 40px;
+ height: 40px;
+ }
+ .lds-ripple div {
+ position: absolute;
+ border: 4px solid #fff;
+ opacity: 1;
+ border-radius: 50%;
+ animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
+ }
+ .lds-ripple div:nth-child(2) {
+ animation-delay: -0.5s;
+ }
+ @keyframes lds-ripple {
+ 0% {
+ top: 1px;
+ left: 1px;
+ width: 0;
+ height: 0;
+ opacity: 1;
+ }
+ 100% {
+ top: 0px;
+ left: 0px;
+ width: 36px;
+ height: 36px;
+ opacity: 0;
+ }
+ }
+</style>
diff --git a/src/routes/databases/[id]/logs/index.json.ts b/src/routes/databases/[id]/logs/index.json.ts
new file mode 100644
index 0000000000..7aff718b43
--- /dev/null
+++ b/src/routes/databases/[id]/logs/index.json.ts
@@ -0,0 +1,66 @@
+import { getUserDetails } from '$lib/common';
+import * as db from '$lib/database';
+import { ErrorHandler } from '$lib/database';
+import { dayjs } from '$lib/dayjs';
+import { dockerInstance } from '$lib/docker';
+import type { RequestHandler } from '@sveltejs/kit';
+
+export const get: RequestHandler = async (event) => {
+ const { status, body } = await getUserDetails(event);
+ if (status === 401) return { status, body };
+
+ const { id } = event.params;
+ let since = event.url.searchParams.get('since') || 0;
+ if (since !== 0) {
+ since = dayjs(since).unix();
+ }
+ try {
+ const { destinationDockerId, destinationDocker } = await db.prisma.database.findUnique({
+ where: { id },
+ include: { destinationDocker: true }
+ });
+ if (destinationDockerId) {
+ const docker = dockerInstance({ destinationDocker });
+ try {
+ const container = await docker.engine.getContainer(id);
+ if (container) {
+ const logs = (
+ await container.logs({
+ stdout: true,
+ stderr: true,
+ timestamps: true,
+ since,
+ tail: 5000
+ })
+ )
+ .toString()
+ .split('\n')
+ .map((l) => l.slice(8))
+ .filter((a) => a);
+ return {
+ body: {
+ logs
+ }
+ };
+ }
+ } catch (error) {
+ const { statusCode } = error;
+ if (statusCode === 404) {
+ return {
+ body: {
+ logs: []
+ }
+ };
+ }
+ }
+ }
+ return {
+ status: 200,
+ body: {
+ message: 'No logs found.'
+ }
+ };
+ } catch (error) {
+ return ErrorHandler(error);
+ }
+};
diff --git a/src/routes/databases/[id]/logs/index.svelte b/src/routes/databases/[id]/logs/index.svelte
new file mode 100644
index 0000000000..8c7e11e727
--- /dev/null
+++ b/src/routes/databases/[id]/logs/index.svelte
@@ -0,0 +1,179 @@
+<script context="module" lang="ts">
+ import type { Load } from '@sveltejs/kit';
+ import { onDestroy, onMount } from 'svelte';
+ export const load: Load = async ({ fetch, params, url, stuff }) => {
+ let endpoint = `/databases/${params.id}/logs.json`;
+ const res = await fetch(endpoint);
+ if (res.ok) {
+ return {
+ props: {
+ database: stuff.database,
+ ...(await res.json())
+ }
+ };
+ }
+
+ return {
+ status: res.status,
+ error: new Error(`Could not load ${url}`)
+ };
+ };
+</script>
+
+<script lang="ts">
+ export let database;
+ import { page } from '$app/stores';
+ import LoadingLogs from './_Loading.svelte';
+ import { get } from '$lib/api';
+ import { errorNotification } from '$lib/form';
+ import { t } from '$lib/translations';
+
+ let loadLogsInterval = null;
+ let logs = [];
+ let lastLog = null;
+ let followingInterval;
+ let followingLogs;
+ let logsEl;
+ let position = 0;
+
+ const { id } = $page.params;
+ onMount(async () => {
+ loadAllLogs();
+ loadLogsInterval = setInterval(() => {
+ loadLogs();
+ }, 1000);
+ });
+ onDestroy(() => {
+ clearInterval(loadLogsInterval);
+ clearInterval(followingInterval);
+ });
+ async function loadAllLogs() {
+ try {
+ const data: any = await get(`/databases/${id}/logs.json`);
+ if (data?.logs) {
+ lastLog = data.logs[data.logs.length - 1];
+ logs = data.logs;
+ }
+ } catch (error) {
+ console.log(error);
+ return errorNotification(error);
+ }
+ }
+ async function loadLogs() {
+ try {
+ const newLogs: any = await get(
+ `/databases/${id}/logs.json?since=${lastLog?.split(' ')[0] || 0}`
+ );
+
+ if (newLogs?.logs && newLogs.logs[newLogs.logs.length - 1] !== logs[logs.length - 1]) {
+ logs = logs.concat(newLogs.logs);
+ lastLog = newLogs.logs[newLogs.logs.length - 1];
+ }
+ } catch (error) {
+ return errorNotification(error);
+ }
+ }
+ function detect() {
+ if (position < logsEl.scrollTop) {
+ position = logsEl.scrollTop;
+ } else {
+ if (followingLogs) {
+ clearInterval(followingInterval);
+ followingLogs = false;
+ }
+ position = logsEl.scrollTop;
+ }
+ }
+
+ function followBuild() {
+ followingLogs = !followingLogs;
+ if (followingLogs) {
+ followingInterval = setInterval(() => {
+ logsEl.scrollTop = logsEl.scrollHeight;
+ window.scrollTo(0, document.body.scrollHeight);
+ }, 1000);
+ } else {
+ clearInterval(followingInterval);
+ }
+ }
+</script>
+
+<div class="flex items-center space-x-2 p-6 text-2xl font-bold">
+ <div class="-mb-5 flex-col">
+ <div class="md:max-w-64 truncate text-base tracking-tight md:text-2xl lg:block">
+ Database Logs
+ </div>
+ <span class="text-xs">{database.name}</span>
+ </div>
+
+ {#if database.fqdn}
+ <a
+ href={database.fqdn}
+ target="_blank"
+ class="icons tooltip-bottom flex items-center bg-transparent text-sm"
+ ><svg
+ xmlns="http://www.w3.org/2000/svg"
+ class="h-6 w-6"
+ viewBox="0 0 24 24"
+ stroke-width="1.5"
+ stroke="currentColor"
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
+ <line x1="10" y1="14" x2="20" y2="4" />
+ <polyline points="15 4 20 4 20 9" />
+ </svg></a
+ >
+ {/if}
+</div>
+<div class="flex flex-row justify-center space-x-2 px-10 pt-6">
+ {#if logs.length === 0}
+ <div class="text-xl font-bold tracking-tighter">{$t('application.build.waiting_logs')}</div>
+ {:else}
+ <div class="relative w-full">
+ <div class="text-right " />
+ {#if loadLogsInterval}
+ <LoadingLogs />
+ {/if}
+ <div class="flex justify-end sticky top-0 p-2 mx-1">
+ <button
+ on:click={followBuild}
+ class="bg-transparent"
+ data-tooltip="Follow logs"
+ class:text-green-500={followingLogs}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ class="w-6 h-6"
+ viewBox="0 0 24 24"
+ stroke-width="1.5"
+ stroke="currentColor"
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <circle cx="12" cy="12" r="9" />
+ <line x1="8" y1="12" x2="12" y2="16" />
+ <line x1="12" y1="8" x2="12" y2="16" />
+ <line x1="16" y1="12" x2="12" y2="16" />
+ </svg>
+ </button>
+ </div>
+ <div
+ class="font-mono w-full leading-6 text-left text-md tracking-tighter rounded bg-coolgray-200 py-5 px-6 whitespace-pre-wrap break-words overflow-auto max-h-[80vh] -mt-12 overflow-y-scroll scrollbar-w-1 scrollbar-thumb-coollabs scrollbar-track-coolgray-200"
+ bind:this={logsEl}
+ on:scroll={detect}
+ >
+ <div class="px-2 pr-14">
+ {#each logs as log}
+ {log + '\n'}
+ {/each}
+ </div>
+ </div>
+ </div>
+ {/if}
+</div>
diff --git a/src/routes/services/[id]/__layout.svelte b/src/routes/services/[id]/__layout.svelte
index 82fbd19c7c..aa7026fd4f 100644
--- a/src/routes/services/[id]/__layout.svelte
+++ b/src/routes/services/[id]/__layout.svelte
@@ -270,6 +270,38 @@
</button></a
>
<div class="border border-stone-700 h-8" />
+ <a
+ href={isRunning ? `/services/${id}/logs` : null}
+ sveltekit:prefetch
+ class="hover:text-pink-500 rounded"
+ class:text-pink-500={$page.url.pathname === `/services/${id}/logs`}
+ class:bg-coolgray-500={$page.url.pathname === `/services/${id}/logs`}
+ >
+ <button
+ title={$t('service.logs')}
+ disabled={!isRunning}
+ class="icons bg-transparent tooltip-bottom text-sm"
+ data-tooltip={$t('service.logs')}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ class="h-6 w-6"
+ viewBox="0 0 24 24"
+ stroke-width="1.5"
+ stroke="currentColor"
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
+ <path d="M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0" />
+ <line x1="3" y1="6" x2="3" y2="19" />
+ <line x1="12" y1="6" x2="12" y2="19" />
+ <line x1="21" y1="6" x2="21" y2="19" />
+ </svg></button
+ ></a
+ >
{/if}
<button
on:click={deleteService}
diff --git a/src/routes/services/[id]/logs/_Loading.svelte b/src/routes/services/[id]/logs/_Loading.svelte
new file mode 100644
index 0000000000..73fbe709e9
--- /dev/null
+++ b/src/routes/services/[id]/logs/_Loading.svelte
@@ -0,0 +1,41 @@
+<div class="lds-ripple absolute left-0">
+ <div />
+ <div />
+</div>
+
+<style>
+ .lds-ripple {
+ display: inline-block;
+ position: relative;
+ left: -19px;
+ top: -8px;
+ width: 40px;
+ height: 40px;
+ }
+ .lds-ripple div {
+ position: absolute;
+ border: 4px solid #fff;
+ opacity: 1;
+ border-radius: 50%;
+ animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
+ }
+ .lds-ripple div:nth-child(2) {
+ animation-delay: -0.5s;
+ }
+ @keyframes lds-ripple {
+ 0% {
+ top: 1px;
+ left: 1px;
+ width: 0;
+ height: 0;
+ opacity: 1;
+ }
+ 100% {
+ top: 0px;
+ left: 0px;
+ width: 36px;
+ height: 36px;
+ opacity: 0;
+ }
+ }
+</style>
diff --git a/src/routes/services/[id]/logs/index.json.ts b/src/routes/services/[id]/logs/index.json.ts
new file mode 100644
index 0000000000..fe94db9ab6
--- /dev/null
+++ b/src/routes/services/[id]/logs/index.json.ts
@@ -0,0 +1,66 @@
+import { getUserDetails } from '$lib/common';
+import * as db from '$lib/database';
+import { ErrorHandler } from '$lib/database';
+import { dayjs } from '$lib/dayjs';
+import { dockerInstance } from '$lib/docker';
+import type { RequestHandler } from '@sveltejs/kit';
+
+export const get: RequestHandler = async (event) => {
+ const { status, body } = await getUserDetails(event);
+ if (status === 401) return { status, body };
+
+ const { id } = event.params;
+ let since = event.url.searchParams.get('since') || 0;
+ if (since !== 0) {
+ since = dayjs(since).unix();
+ }
+ try {
+ const { destinationDockerId, destinationDocker } = await db.prisma.service.findUnique({
+ where: { id },
+ include: { destinationDocker: true }
+ });
+ if (destinationDockerId) {
+ const docker = dockerInstance({ destinationDocker });
+ try {
+ const container = await docker.engine.getContainer(id);
+ if (container) {
+ const logs = (
+ await container.logs({
+ stdout: true,
+ stderr: true,
+ timestamps: true,
+ since,
+ tail: 5000
+ })
+ )
+ .toString()
+ .split('\n')
+ .map((l) => l.slice(8))
+ .filter((a) => a);
+ return {
+ body: {
+ logs
+ }
+ };
+ }
+ } catch (error) {
+ const { statusCode } = error;
+ if (statusCode === 404) {
+ return {
+ body: {
+ logs: []
+ }
+ };
+ }
+ }
+ }
+ return {
+ status: 200,
+ body: {
+ message: 'No logs found.'
+ }
+ };
+ } catch (error) {
+ return ErrorHandler(error);
+ }
+};
diff --git a/src/routes/services/[id]/logs/index.svelte b/src/routes/services/[id]/logs/index.svelte
new file mode 100644
index 0000000000..bda5b8044e
--- /dev/null
+++ b/src/routes/services/[id]/logs/index.svelte
@@ -0,0 +1,179 @@
+<script context="module" lang="ts">
+ import type { Load } from '@sveltejs/kit';
+ import { onDestroy, onMount } from 'svelte';
+ export const load: Load = async ({ fetch, params, url, stuff }) => {
+ let endpoint = `/services/${params.id}/logs.json`;
+ const res = await fetch(endpoint);
+ if (res.ok) {
+ return {
+ props: {
+ service: stuff.service,
+ ...(await res.json())
+ }
+ };
+ }
+
+ return {
+ status: res.status,
+ error: new Error(`Could not load ${url}`)
+ };
+ };
+</script>
+
+<script lang="ts">
+ export let service;
+ import { page } from '$app/stores';
+ import LoadingLogs from './_Loading.svelte';
+ import { get } from '$lib/api';
+ import { errorNotification } from '$lib/form';
+ import { t } from '$lib/translations';
+
+ let loadLogsInterval = null;
+ let logs = [];
+ let lastLog = null;
+ let followingInterval;
+ let followingLogs;
+ let logsEl;
+ let position = 0;
+
+ const { id } = $page.params;
+ onMount(async () => {
+ loadAllLogs();
+ loadLogsInterval = setInterval(() => {
+ loadLogs();
+ }, 1000);
+ });
+ onDestroy(() => {
+ clearInterval(loadLogsInterval);
+ clearInterval(followingInterval);
+ });
+ async function loadAllLogs() {
+ try {
+ const data: any = await get(`/services/${id}/logs.json`);
+ if (data?.logs) {
+ lastLog = data.logs[data.logs.length - 1];
+ logs = data.logs;
+ }
+ } catch (error) {
+ console.log(error);
+ return errorNotification(error);
+ }
+ }
+ async function loadLogs() {
+ try {
+ const newLogs: any = await get(
+ `/services/${id}/logs.json?since=${lastLog?.split(' ')[0] || 0}`
+ );
+
+ if (newLogs?.logs && newLogs.logs[newLogs.logs.length - 1] !== logs[logs.length - 1]) {
+ logs = logs.concat(newLogs.logs);
+ lastLog = newLogs.logs[newLogs.logs.length - 1];
+ }
+ } catch (error) {
+ return errorNotification(error);
+ }
+ }
+ function detect() {
+ if (position < logsEl.scrollTop) {
+ position = logsEl.scrollTop;
+ } else {
+ if (followingLogs) {
+ clearInterval(followingInterval);
+ followingLogs = false;
+ }
+ position = logsEl.scrollTop;
+ }
+ }
+
+ function followBuild() {
+ followingLogs = !followingLogs;
+ if (followingLogs) {
+ followingInterval = setInterval(() => {
+ logsEl.scrollTop = logsEl.scrollHeight;
+ window.scrollTo(0, document.body.scrollHeight);
+ }, 1000);
+ } else {
+ clearInterval(followingInterval);
+ }
+ }
+</script>
+
+<div class="flex items-center space-x-2 p-6 text-2xl font-bold">
+ <div class="-mb-5 flex-col">
+ <div class="md:max-w-64 truncate text-base tracking-tight md:text-2xl lg:block">
+ Service Logs
+ </div>
+ <span class="text-xs">{service.name}</span>
+ </div>
+
+ {#if service.fqdn}
+ <a
+ href={service.fqdn}
+ target="_blank"
+ class="icons tooltip-bottom flex items-center bg-transparent text-sm"
+ ><svg
+ xmlns="http://www.w3.org/2000/svg"
+ class="h-6 w-6"
+ viewBox="0 0 24 24"
+ stroke-width="1.5"
+ stroke="currentColor"
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <path d="M11 7h-5a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-5" />
+ <line x1="10" y1="14" x2="20" y2="4" />
+ <polyline points="15 4 20 4 20 9" />
+ </svg></a
+ >
+ {/if}
+</div>
+<div class="flex flex-row justify-center space-x-2 px-10 pt-6">
+ {#if logs.length === 0}
+ <div class="text-xl font-bold tracking-tighter">{$t('application.build.waiting_logs')}</div>
+ {:else}
+ <div class="relative w-full">
+ <div class="text-right " />
+ {#if loadLogsInterval}
+ <LoadingLogs />
+ {/if}
+ <div class="flex justify-end sticky top-0 p-2 mx-1">
+ <button
+ on:click={followBuild}
+ class="bg-transparent"
+ data-tooltip="Follow logs"
+ class:text-green-500={followingLogs}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ class="w-6 h-6"
+ viewBox="0 0 24 24"
+ stroke-width="1.5"
+ stroke="currentColor"
+ fill="none"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
+ <circle cx="12" cy="12" r="9" />
+ <line x1="8" y1="12" x2="12" y2="16" />
+ <line x1="12" y1="8" x2="12" y2="16" />
+ <line x1="16" y1="12" x2="12" y2="16" />
+ </svg>
+ </button>
+ </div>
+ <div
+ class="font-mono w-full leading-6 text-left text-md tracking-tighter rounded bg-coolgray-200 py-5 px-6 whitespace-pre-wrap break-words overflow-auto max-h-[80vh] -mt-12 overflow-y-scroll scrollbar-w-1 scrollbar-thumb-coollabs scrollbar-track-coolgray-200"
+ bind:this={logsEl}
+ on:scroll={detect}
+ >
+ <div class="px-2 pr-14">
+ {#each logs as log}
+ {log + '\n'}
+ {/each}
+ </div>
+ </div>
+ </div>
+ {/if}
+</div>