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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: Unnecessary proxy restart feat: Restart proxy
Andras Bacsai1df81b8698ba
diff --git a/src/lib/haproxy/index.ts b/src/lib/haproxy/index.tsindex d1c32acf05..62e44f45af 100644--- a/src/lib/haproxy/index.ts+++ b/src/lib/haproxy/index.ts@@ -605,7 +605,7 @@ export async function removeWwwRedirection(domain) {export async function setWwwRedirection(fqdn) {const haproxy = await haproxyInstance();await checkHAProxy(haproxy);- const transactionId = await getNextTransactionId();+ let transactionId;try {const domain = getDomain(fqdn);@@ -629,6 +629,7 @@ export async function setWwwRedirection(fqdn) {nextRule = rules.data[rules.data.length - 1].index + 1;}const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`;+ transactionId = await getNextTransactionId();await haproxy.post(`v2/services/haproxy/configuration/http_request_rules`, {searchParams: {@@ -651,6 +652,6 @@ export async function setWwwRedirection(fqdn) {console.log(error);throw error;} finally {- await completeTransaction(transactionId);+ if (transactionId) await completeTransaction(transactionId);}}diff --git a/src/routes/destinations/[id]/_LocalDocker.svelte b/src/routes/destinations/[id]/_LocalDocker.svelteindex 646752a3b9..a25af53bd5 100644--- a/src/routes/destinations/[id]/_LocalDocker.svelte+++ b/src/routes/destinations/[id]/_LocalDocker.svelte@@ -14,6 +14,7 @@let cannotDisable = settings.fqdn && destination.engine === '/var/run/docker.sock';// let scannedApps = [];let loading = false;+ let restarting = false;async function handleSubmit() {loading = true;try {@@ -102,20 +103,16 @@}async function forceRestartProxy() {try {+ restarting = true;toast.push('Coolify Proxy restarting...');- await post(`/destinations/${id}/stop.json`, { engine: destination.engine });- await post(`/destinations/${id}/settings.json`, {- isCoolifyProxyUsed: false,- engine: destination.engine- });- await post(`/destinations/${id}/start.json`, { engine: destination.engine });- await post(`/destinations/${id}/settings.json`, {- isCoolifyProxyUsed: true,- engine: destination.engine+ await post(`/destinations/${id}/restart.json`, {+ engine: destination.engine,+ fqdn: settings.fqdn});- window.location.reload();} catch ({ error }) {- return errorNotification(error);+ setTimeout(() => {+ window.location.reload();+ }, 5000);}}</script>@@ -132,6 +129,12 @@disabled={loading}>{loading ? 'Saving...' : 'Save'}</button>+ <button+ class={restarting ? '' : 'bg-red-600 hover:bg-red-500'}+ disabled={restarting}+ on:click|preventDefault={forceRestartProxy}+ >{restarting ? 'Restarting... please wait...' : 'Force restart proxy'}</button+ ><!-- <button type="button" class="bg-coollabs hover:bg-coollabs-100" on:click={scanApps}>Scan for applications</button> -->@@ -187,7 +190,6 @@: ''}`}/>- <button on:click|preventDefault={forceRestartProxy}>Force Restart Proxy</button></ul></div></form>diff --git a/src/routes/destinations/[id]/restart.json.ts b/src/routes/destinations/[id]/restart.json.tsnew file mode 100644index 0000000000..b3efa60da3--- /dev/null+++ b/src/routes/destinations/[id]/restart.json.ts@@ -0,0 +1,34 @@+import { getDomain, getUserDetails } from '$lib/common';+import { ErrorHandler } from '$lib/database';+import * as db from '$lib/database';+import {+ configureCoolifyProxyOn,+ forceSSLOnApplication,+ setWwwRedirection,+ startCoolifyProxy,+ stopCoolifyProxy+} from '$lib/haproxy';+import type { RequestHandler } from '@sveltejs/kit';++export const post: RequestHandler = async (event) => {+ const { teamId, status, body } = await getUserDetails(event);+ if (status === 401) return { status, body };++ const { engine, fqdn } = await event.request.json();++ try {+ const domain = getDomain(fqdn);+ await stopCoolifyProxy(engine);+ await startCoolifyProxy(engine);+ await db.setDestinationSettings({ engine, isCoolifyProxyUsed: true });+ await configureCoolifyProxyOn(fqdn);+ await setWwwRedirection(fqdn);+ const isHttps = fqdn.startsWith('https://');+ if (isHttps) await forceSSLOnApplication({ domain });+ return {+ status: 200+ };+ } catch (error) {+ return ErrorHandler(error);+ }+};