fix: plausible analytics things
This commit is contained in:
parent
b5756cb14f
commit
fda8823050
@ -88,15 +88,18 @@ export async function migrateServicesToNewTemplate() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const service of Object.keys(template.services)) {
|
for (const s of Object.keys(template.services)) {
|
||||||
if (template.services[service].volumes) {
|
if (service.type === 'plausibleanalytics') {
|
||||||
for (const volume of template.services[service].volumes) {
|
continue;
|
||||||
|
}
|
||||||
|
if (template.services[s].volumes) {
|
||||||
|
for (const volume of template.services[s].volumes) {
|
||||||
const [volumeName, path] = volume.split(':')
|
const [volumeName, path] = volume.split(':')
|
||||||
if (!volumeName.startsWith('/')) {
|
if (!volumeName.startsWith('/')) {
|
||||||
const found = await prisma.servicePersistentStorage.findFirst({ where: { volumeName, serviceId: id } })
|
const found = await prisma.servicePersistentStorage.findFirst({ where: { volumeName, serviceId: id } })
|
||||||
if (!found) {
|
if (!found) {
|
||||||
await prisma.servicePersistentStorage.create({
|
await prisma.servicePersistentStorage.create({
|
||||||
data: { volumeName, path, containerId: service, predefined: true, service: { connect: { id } } }
|
data: { volumeName, path, containerId: s, predefined: true, service: { connect: { id } } }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,9 +467,13 @@ async function createVolumes(service: any, template: any) {
|
|||||||
for (const s of Object.keys(template.services)) {
|
for (const s of Object.keys(template.services)) {
|
||||||
if (template.services[s].volumes && template.services[s].volumes.length > 0) {
|
if (template.services[s].volumes && template.services[s].volumes.length > 0) {
|
||||||
for (const volume of template.services[s].volumes) {
|
for (const volume of template.services[s].volumes) {
|
||||||
const volumeName = volume.split(':')[0]
|
let volumeName = volume.split(':')[0]
|
||||||
const volumePath = volume.split(':')[1]
|
const volumePath = volume.split(':')[1]
|
||||||
const volumeService = s
|
let volumeService = s
|
||||||
|
if (service.type === 'plausibleanalytics' && service.plausibleAnalytics?.id) {
|
||||||
|
let volumeId = volumeName.split('-')[0]
|
||||||
|
volumeName = volumeName.replace(volumeId, service.plausibleAnalytics.id)
|
||||||
|
}
|
||||||
volumes.push(`${volumeName}@@@${volumePath}@@@${volumeService}`)
|
volumes.push(`${volumeName}@@@${volumePath}@@@${volumeService}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1448,8 @@ export async function getServiceFromDB({
|
|||||||
persistentStorage: true,
|
persistentStorage: true,
|
||||||
serviceSecret: true,
|
serviceSecret: true,
|
||||||
serviceSetting: true,
|
serviceSetting: true,
|
||||||
wordpress: true
|
wordpress: true,
|
||||||
|
plausibleAnalytics: true,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!body) {
|
if (!body) {
|
||||||
|
@ -78,12 +78,28 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const customVolumes = await prisma.servicePersistentStorage.findMany({ where: { serviceId: id } })
|
const customVolumes = await prisma.servicePersistentStorage.findMany({ where: { serviceId: id } })
|
||||||
let volumes = arm ? template.services[s].volumesArm : template.services[s].volumes
|
let volumes = new Set()
|
||||||
|
if (arm) {
|
||||||
|
template.services[s]?.volumesArm && template.services[s].volumesArm.length > 0 && template.services[s].volumesArm.forEach(v => volumes.add(v))
|
||||||
|
} else {
|
||||||
|
template.services[s]?.volumes && template.services[s].volumes.length > 0 && template.services[s].volumes.forEach(v => volumes.add(v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround: old plausible analytics service wrong volume id name
|
||||||
|
if (service.type === 'plausibleanalytics' && service.plausibleAnalytics?.id) {
|
||||||
|
let temp = Array.from(volumes)
|
||||||
|
temp.forEach(a => {
|
||||||
|
const t = a.replace(service.id, service.plausibleAnalytics.id)
|
||||||
|
volumes.delete(a)
|
||||||
|
volumes.add(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (customVolumes.length > 0) {
|
if (customVolumes.length > 0) {
|
||||||
for (const customVolume of customVolumes) {
|
for (const customVolume of customVolumes) {
|
||||||
const { volumeName, path, containerId } = customVolume
|
const { volumeName, path, containerId } = customVolume
|
||||||
if (volumes && volumes.length > 0 && !volumes.includes(`${volumeName}:${path}`) && containerId === service) {
|
if (volumes && volumes.size > 0 && !volumes.has(`${volumeName}:${path}`) && containerId === service) {
|
||||||
volumes.push(`${volumeName}:${path}`)
|
volumes.add(`${volumeName}:${path}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +112,7 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
|
|||||||
image: arm ? template.services[s].imageArm : template.services[s].image,
|
image: arm ? template.services[s].imageArm : template.services[s].image,
|
||||||
expose: template.services[s].ports,
|
expose: template.services[s].ports,
|
||||||
...(exposePort ? { ports: [`${exposePort}:${exposePort}`] } : {}),
|
...(exposePort ? { ports: [`${exposePort}:${exposePort}`] } : {}),
|
||||||
volumes,
|
volumes: Array.from(volumes),
|
||||||
environment: newEnvironments,
|
environment: newEnvironments,
|
||||||
depends_on: template.services[s]?.depends_on,
|
depends_on: template.services[s]?.depends_on,
|
||||||
ulimits: template.services[s]?.ulimits,
|
ulimits: template.services[s]?.ulimits,
|
||||||
@ -141,6 +157,8 @@ export async function startService(request: FastifyRequest<ServiceStartStop>, fa
|
|||||||
const composeFileDestination = `${workdir}/docker-compose.yaml`;
|
const composeFileDestination = `${workdir}/docker-compose.yaml`;
|
||||||
await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
|
await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
|
||||||
await startServiceContainers(fastify, id, teamId, destinationDocker.id, composeFileDestination)
|
await startServiceContainers(fastify, id, teamId, destinationDocker.id, composeFileDestination)
|
||||||
|
|
||||||
|
// Workaround: Stop old minio proxies
|
||||||
if (service.type === 'minio') {
|
if (service.type === 'minio') {
|
||||||
try {
|
try {
|
||||||
await executeDockerCmd({
|
await executeDockerCmd({
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
async function restartService() {
|
async function restartService() {
|
||||||
const sure = confirm('Are you sure you want to restart this service?');
|
const sure = confirm('Are you sure you want to restart this service?');
|
||||||
if (sure) {
|
if (sure) {
|
||||||
await stopService();
|
await stopService(true);
|
||||||
await startService();
|
await startService();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +120,27 @@
|
|||||||
loading.refreshTemplates = false;
|
loading.refreshTemplates = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function stopService() {
|
async function stopService(skip = false) {
|
||||||
|
if (skip) {
|
||||||
|
$status.service.initialLoading = true;
|
||||||
|
$status.service.loading = true;
|
||||||
|
try {
|
||||||
|
await post(`/services/${service.id}/stop`, {});
|
||||||
|
if (service.type.startsWith('wordpress')) {
|
||||||
|
await post(`/services/${id}/wordpress/ftp`, {
|
||||||
|
ftpEnabled: false
|
||||||
|
});
|
||||||
|
service.wordpress?.ftpEnabled && window.location.reload();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return errorNotification(error);
|
||||||
|
} finally {
|
||||||
|
$status.service.initialLoading = false;
|
||||||
|
$status.service.loading = false;
|
||||||
|
await getStatus();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
const sure = confirm($t('database.confirm_stop', { name: service.name }));
|
const sure = confirm($t('database.confirm_stop', { name: service.name }));
|
||||||
if (sure) {
|
if (sure) {
|
||||||
$status.service.initialLoading = true;
|
$status.service.initialLoading = true;
|
||||||
@ -319,7 +339,7 @@
|
|||||||
Force Redeploy
|
Force Redeploy
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
on:click={stopService}
|
on:click={() => stopService(false)}
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={!$isDeploymentEnabled}
|
disabled={!$isDeploymentEnabled}
|
||||||
class="btn btn-sm gap-2"
|
class="btn btn-sm gap-2"
|
||||||
|
Loading…
Reference in New Issue
Block a user