feat: cleanup clickhouse db
This commit is contained in:
parent
9eeadd5882
commit
7dbde842d7
@ -2653,6 +2653,27 @@ export async function activatePlausibleUsers(request: FastifyRequest<OnlyId>, re
|
||||
return errorHandler({ status, message })
|
||||
}
|
||||
}
|
||||
export async function cleanupPlausibleLogs(request: FastifyRequest<OnlyId>, reply: FastifyReply) {
|
||||
try {
|
||||
const { id } = request.params
|
||||
const teamId = request.user.teamId;
|
||||
const {
|
||||
destinationDockerId,
|
||||
destinationDocker,
|
||||
plausibleAnalytics: { postgresqlUser, postgresqlPassword, postgresqlDatabase }
|
||||
} = await getServiceFromDB({ id, teamId });
|
||||
if (destinationDockerId) {
|
||||
await executeDockerCmd({
|
||||
dockerId: destinationDocker.id,
|
||||
command: `docker exec ${id}-clickhouse 'clickhouse-client -q "SELECT name FROM system.tables WHERE name LIKE '%log%';" | xargs -I{} clickhouse-client -q "TRUNCATE TABLE system.{};"'`
|
||||
})
|
||||
return await reply.code(201).send()
|
||||
}
|
||||
throw { status: 500, message: 'Could cleanup logs.' }
|
||||
} catch ({ status, message }) {
|
||||
return errorHandler({ status, message })
|
||||
}
|
||||
}
|
||||
export async function activateWordpressFtp(request: FastifyRequest<ActivateWordpressFtp>, reply: FastifyReply) {
|
||||
const { id } = request.params
|
||||
const { ftpEnabled } = request.body;
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
activateWordpressFtp,
|
||||
checkService,
|
||||
checkServiceDomain,
|
||||
cleanupPlausibleLogs,
|
||||
deleteService,
|
||||
deleteServiceSecret,
|
||||
deleteServiceStorage,
|
||||
@ -74,6 +75,7 @@ const root: FastifyPluginAsync = async (fastify): Promise<void> => {
|
||||
fastify.post<ServiceStartStop & SetWordpressSettings>('/:id/:type/settings', async (request, reply) => await setSettingsService(request, reply));
|
||||
|
||||
fastify.post<OnlyId>('/:id/plausibleanalytics/activate', async (request, reply) => await activatePlausibleUsers(request, reply));
|
||||
fastify.post<OnlyId>('/:id/plausibleanalytics/cleanup', async (request, reply) => await cleanupPlausibleLogs(request, reply));
|
||||
fastify.post<ActivateWordpressFtp>('/:id/wordpress/ftp', async (request, reply) => await activateWordpressFtp(request, reply));
|
||||
};
|
||||
|
||||
|
@ -126,7 +126,7 @@
|
||||
<a
|
||||
sveltekit:prefetch
|
||||
href="/"
|
||||
class="icons tooltip tooltip-right tooltip-primary bg-coolgray-200 hover:text-white"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200 hover:text-white"
|
||||
class:text-white={$page.url.pathname === '/'}
|
||||
class:bg-coolgray-500={$page.url.pathname === '/'}
|
||||
data-tip="Dashboard"
|
||||
@ -245,7 +245,7 @@
|
||||
<a
|
||||
sveltekit:prefetch
|
||||
href="/databases"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class:text-databases={$page.url.pathname.startsWith('/databases') ||
|
||||
$page.url.pathname.startsWith('/new/database')}
|
||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/databases') ||
|
||||
@ -271,7 +271,7 @@
|
||||
<a
|
||||
sveltekit:prefetch
|
||||
href="/services"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class:text-services={$page.url.pathname.startsWith('/services') ||
|
||||
$page.url.pathname.startsWith('/new/service')}
|
||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/services') ||
|
||||
@ -300,7 +300,7 @@
|
||||
<a
|
||||
sveltekit:prefetch
|
||||
href="/iam"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class:text-iam={$page.url.pathname.startsWith('/iam')}
|
||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/iam')}
|
||||
data-tip="IAM"
|
||||
@ -324,7 +324,7 @@
|
||||
<a
|
||||
sveltekit:prefetch
|
||||
href={$appSession.teamId === '0' ? '/settings/global' : '/settings/ssh-keys'}
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200"
|
||||
class:text-settings={$page.url.pathname.startsWith('/settings')}
|
||||
class:bg-coolgray-500={$page.url.pathname.startsWith('/settings')}
|
||||
data-tip="Settings"
|
||||
@ -348,7 +348,7 @@
|
||||
</a>
|
||||
|
||||
<div
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200 hover:text-error"
|
||||
class="icons tooltip tooltip-primary tooltip-right bg-coolgray-200 hover:text-error"
|
||||
data-tip="Logout"
|
||||
on:click={logout}
|
||||
>
|
||||
|
@ -352,7 +352,7 @@
|
||||
>
|
||||
<button
|
||||
disabled={$disabledButton}
|
||||
class="icons bg-transparent tooltip tooltip-bottom text-sm"
|
||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
||||
data-tip="Secret"
|
||||
>
|
||||
<svg
|
||||
@ -507,7 +507,7 @@
|
||||
type="submit"
|
||||
disabled={!$appSession.isAdmin}
|
||||
class:hover:text-red-500={$appSession.isAdmin}
|
||||
class="icons bg-transparent tooltip tooltip-bottom text-sm"
|
||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm"
|
||||
data-tip={$appSession.isAdmin
|
||||
? $t('application.delete_application')
|
||||
: $t('application.permission_denied_delete_application')}
|
||||
|
@ -249,7 +249,7 @@
|
||||
class:bg-coolgray-500={$page.url.pathname === `/databases/${id}`}
|
||||
>
|
||||
<button
|
||||
class="icons bg-transparent tooltip tooltip-bottom text-sm disabled:text-red-500"
|
||||
class="icons bg-transparent tooltip tooltip-primary tooltip-bottom text-sm disabled:text-red-500"
|
||||
data-tip={$t('application.configurations')}
|
||||
>
|
||||
<svg
|
||||
|
@ -125,6 +125,17 @@
|
||||
return errorNotification(error);
|
||||
}
|
||||
}
|
||||
async function cleanupLogs() {
|
||||
try {
|
||||
await post(`/services/${id}/${service.type}/cleanup`, { id: service.id });
|
||||
return addToast({
|
||||
message: 'Cleared DB Logs',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
return errorNotification(error);
|
||||
}
|
||||
}
|
||||
onMount(async () => {
|
||||
if (browser && window.location.hostname === 'demo.coolify.io' && !service.fqdn) {
|
||||
service.fqdn = `http://${cuid()}.demo.coolify.io`;
|
||||
@ -170,11 +181,14 @@
|
||||
>
|
||||
{/if}
|
||||
{#if service.type === 'plausibleanalytics' && $status.service.isRunning}
|
||||
<button on:click|preventDefault={setEmailsToVerified} disabled={loadingVerification}
|
||||
<button class="btn btn-sm" on:click|preventDefault={setEmailsToVerified} disabled={loadingVerification}
|
||||
>{loadingVerification
|
||||
? $t('forms.verifying')
|
||||
: $t('forms.verify_emails_without_smtp')}</button
|
||||
>
|
||||
<button class="btn btn-sm" on:click|preventDefault={cleanupLogs}
|
||||
>Cleanup Unnecessary Database Logs</button
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
@ -91,11 +91,8 @@ label {
|
||||
@apply inline-block w-64 text-xs tracking-tight md:text-sm;
|
||||
}
|
||||
.btn {
|
||||
@apply text-white tracking-tighter;
|
||||
@apply text-white text-base;
|
||||
}
|
||||
/*button, .button {
|
||||
@apply rounded bg-coolgray-200 p-2 px-3 text-sm outline-none transition-all duration-100 hover:bg-coolgray-500 disabled:cursor-not-allowed disabled:bg-coolblack disabled:text-stone-600;
|
||||
}*/
|
||||
|
||||
a {
|
||||
@apply underline hover:text-white;
|
||||
|
Loading…
x
Reference in New Issue
Block a user