fix: TransactionIds
This commit is contained in:
parent
b29c1e702a
commit
305a95fa74
@ -71,7 +71,7 @@ export async function forceSSLOffApplication({ domain }) {
|
|||||||
if (!dev) {
|
if (!dev) {
|
||||||
const haproxy = await haproxyInstance();
|
const haproxy = await haproxyInstance();
|
||||||
await checkHAProxy(haproxy);
|
await checkHAProxy(haproxy);
|
||||||
const transactionId = await getNextTransactionId();
|
let transactionId;
|
||||||
try {
|
try {
|
||||||
const rules: any = await haproxy
|
const rules: any = await haproxy
|
||||||
.get(`v2/services/haproxy/configuration/http_request_rules`, {
|
.get(`v2/services/haproxy/configuration/http_request_rules`, {
|
||||||
@ -84,6 +84,8 @@ export async function forceSSLOffApplication({ domain }) {
|
|||||||
if (rules.data.length > 0) {
|
if (rules.data.length > 0) {
|
||||||
const rule = rules.data.find((rule) => rule.cond_test.includes(`-i ${domain}`));
|
const rule = rules.data.find((rule) => rule.cond_test.includes(`-i ${domain}`));
|
||||||
if (rule) {
|
if (rule) {
|
||||||
|
transactionId = await getNextTransactionId();
|
||||||
|
|
||||||
await haproxy
|
await haproxy
|
||||||
.delete(`v2/services/haproxy/configuration/http_request_rules/${rule.index}`, {
|
.delete(`v2/services/haproxy/configuration/http_request_rules/${rule.index}`, {
|
||||||
searchParams: {
|
searchParams: {
|
||||||
@ -98,7 +100,7 @@ export async function forceSSLOffApplication({ domain }) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
} finally {
|
} finally {
|
||||||
await completeTransaction(transactionId);
|
if (transactionId) await completeTransaction(transactionId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`[DEBUG] Removing ssl for ${domain}`);
|
console.log(`[DEBUG] Removing ssl for ${domain}`);
|
||||||
@ -108,8 +110,7 @@ export async function forceSSLOnApplication({ domain }) {
|
|||||||
if (!dev) {
|
if (!dev) {
|
||||||
const haproxy = await haproxyInstance();
|
const haproxy = await haproxyInstance();
|
||||||
await checkHAProxy(haproxy);
|
await checkHAProxy(haproxy);
|
||||||
const transactionId = await getNextTransactionId();
|
let transactionId;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const rules: any = await haproxy
|
const rules: any = await haproxy
|
||||||
.get(`v2/services/haproxy/configuration/http_request_rules`, {
|
.get(`v2/services/haproxy/configuration/http_request_rules`, {
|
||||||
@ -127,6 +128,8 @@ export async function forceSSLOnApplication({ domain }) {
|
|||||||
if (rule) return;
|
if (rule) return;
|
||||||
nextRule = rules.data[rules.data.length - 1].index + 1;
|
nextRule = rules.data[rules.data.length - 1].index + 1;
|
||||||
}
|
}
|
||||||
|
transactionId = await getNextTransactionId();
|
||||||
|
|
||||||
await haproxy
|
await haproxy
|
||||||
.post(`v2/services/haproxy/configuration/http_request_rules`, {
|
.post(`v2/services/haproxy/configuration/http_request_rules`, {
|
||||||
searchParams: {
|
searchParams: {
|
||||||
@ -149,7 +152,7 @@ export async function forceSSLOnApplication({ domain }) {
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
throw error;
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
await completeTransaction(transactionId);
|
if (transactionId) await completeTransaction(transactionId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`[DEBUG] Adding ssl for ${domain}`);
|
console.log(`[DEBUG] Adding ssl for ${domain}`);
|
||||||
@ -159,9 +162,10 @@ export async function forceSSLOnApplication({ domain }) {
|
|||||||
export async function deleteProxy({ id }) {
|
export async function deleteProxy({ id }) {
|
||||||
const haproxy = await haproxyInstance();
|
const haproxy = await haproxyInstance();
|
||||||
await checkHAProxy(haproxy);
|
await checkHAProxy(haproxy);
|
||||||
const transactionId = await getNextTransactionId();
|
let transactionId;
|
||||||
try {
|
try {
|
||||||
await haproxy.get(`v2/services/haproxy/configuration/backends/${id}`).json();
|
await haproxy.get(`v2/services/haproxy/configuration/backends/${id}`).json();
|
||||||
|
transactionId = await getNextTransactionId();
|
||||||
await haproxy
|
await haproxy
|
||||||
.delete(`v2/services/haproxy/configuration/backends/${id}`, {
|
.delete(`v2/services/haproxy/configuration/backends/${id}`, {
|
||||||
searchParams: {
|
searchParams: {
|
||||||
@ -180,7 +184,7 @@ export async function deleteProxy({ id }) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error.response.body);
|
console.log(error.response.body);
|
||||||
} finally {
|
} finally {
|
||||||
await completeTransaction(transactionId);
|
if (transactionId) await completeTransaction(transactionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,8 +278,8 @@ export async function configureCoolifyProxyOff(fqdn) {
|
|||||||
await checkHAProxy(haproxy);
|
await checkHAProxy(haproxy);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const transactionId = await getNextTransactionId();
|
|
||||||
await haproxy.get(`v2/services/haproxy/configuration/backends/${domain}`).json();
|
await haproxy.get(`v2/services/haproxy/configuration/backends/${domain}`).json();
|
||||||
|
const transactionId = await getNextTransactionId();
|
||||||
await haproxy
|
await haproxy
|
||||||
.delete(`v2/services/haproxy/configuration/backends/${domain}`, {
|
.delete(`v2/services/haproxy/configuration/backends/${domain}`, {
|
||||||
searchParams: {
|
searchParams: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user