feat: Use tags in update
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
checking: false,
|
||||
success: null
|
||||
};
|
||||
|
||||
let latestVersion = 'latest';
|
||||
onMount(async () => {
|
||||
if ($session.uid) {
|
||||
try {
|
||||
@@ -63,6 +63,7 @@
|
||||
try {
|
||||
const data = await get(`/update.json`);
|
||||
if (data?.isUpdateAvailable) {
|
||||
latestVersion = data.latestVersion;
|
||||
await post(`/update.json`, { type: 'pull' });
|
||||
}
|
||||
isUpdateAvailable = data?.isUpdateAvailable;
|
||||
@@ -95,54 +96,53 @@
|
||||
|
||||
async function update() {
|
||||
updateStatus.loading = true;
|
||||
if (!dev) {
|
||||
try {
|
||||
await post(`/update.json`, { type: 'update' });
|
||||
toast.push('Update completed. Waiting for the new version to start...');
|
||||
let reachable = false;
|
||||
let tries = 0;
|
||||
do {
|
||||
await asyncSleep(4000);
|
||||
try {
|
||||
await get(`/undead.json`);
|
||||
reachable = true;
|
||||
} catch (error) {
|
||||
reachable = false;
|
||||
}
|
||||
if (reachable) break;
|
||||
tries++;
|
||||
} while (!reachable || tries < 120);
|
||||
toast.push('New version reachable. Reloading...');
|
||||
updateStatus.loading = false;
|
||||
updateStatus.success = true;
|
||||
await asyncSleep(3000);
|
||||
return window.location.reload();
|
||||
} catch ({ error }) {
|
||||
return errorNotification(error);
|
||||
} finally {
|
||||
updateStatus.success = false;
|
||||
updateStatus.loading = false;
|
||||
}
|
||||
} else {
|
||||
// if (!dev) {
|
||||
try {
|
||||
await post(`/update.json`, { type: 'update', latestVersion });
|
||||
toast.push('Update completed. Waiting for the new version to start...');
|
||||
let reachable = false;
|
||||
let tries = 0;
|
||||
do {
|
||||
await asyncSleep(1000);
|
||||
await asyncSleep(4000);
|
||||
try {
|
||||
await get(`/undead.json`);
|
||||
reachable = true;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
reachable = false;
|
||||
}
|
||||
console.log(reachable);
|
||||
if (reachable) break;
|
||||
tries++;
|
||||
} while (!reachable || tries < 120);
|
||||
toast.push('New version reachable. Reloading...');
|
||||
await asyncSleep(2000);
|
||||
window.location.reload();
|
||||
updateStatus.loading = false;
|
||||
updateStatus.success = true;
|
||||
await asyncSleep(3000);
|
||||
return window.location.reload();
|
||||
} catch ({ error }) {
|
||||
return errorNotification(error);
|
||||
} finally {
|
||||
updateStatus.success = false;
|
||||
updateStatus.loading = false;
|
||||
}
|
||||
// } else {
|
||||
// let reachable = false;
|
||||
// let tries = 0;
|
||||
// do {
|
||||
// await asyncSleep(1000);
|
||||
// try {
|
||||
// await get(`/undead.json`);
|
||||
// reachable = true;
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// reachable = false;
|
||||
// }
|
||||
// if (reachable) break;
|
||||
// tries++;
|
||||
// } while (!reachable || tries < 120);
|
||||
// toast.push('New version reachable. Reloading...');
|
||||
// await asyncSleep(2000);
|
||||
// window.location.reload();
|
||||
// }
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@@ -12,7 +12,7 @@ export const get: RequestHandler = async () => {
|
||||
const versions = await got
|
||||
.get(`https://get.coollabs.io/versions.json?appId=${process.env['COOLIFY_APP_ID']}`)
|
||||
.json();
|
||||
const latestVersion = versions['coolify'].main.version;
|
||||
const latestVersion = dev ? '10.0.0' : versions['coolify'].main.version;
|
||||
const isUpdateAvailable = compare(latestVersion, currentVersion);
|
||||
return {
|
||||
body: {
|
||||
@@ -26,7 +26,7 @@ export const get: RequestHandler = async () => {
|
||||
};
|
||||
|
||||
export const post: RequestHandler = async (event) => {
|
||||
const { type } = await event.request.json();
|
||||
const { type, latestVersion } = await event.request.json();
|
||||
if (type === 'pull') {
|
||||
try {
|
||||
if (!dev) {
|
||||
@@ -50,13 +50,14 @@ export const post: RequestHandler = async (event) => {
|
||||
try {
|
||||
if (!dev) {
|
||||
await asyncExecShell(
|
||||
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:latest /bin/sh -c "env | grep COOLIFY > .env && docker stop -t 0 coolify && docker stop -t 0 coolify-redis && docker compose up -d --force-recreate"`
|
||||
`docker run --rm -tid --env-file .env -v /var/run/docker.sock:/var/run/docker.sock -v coolify-db coollabsio/coolify:latest /bin/sh -c "env | grep COOLIFY > .env && docker stop -t 0 coolify && docker stop -t 0 coolify-redis && export TAG=${latestVersion} && docker compose up -d --force-recreate"`
|
||||
);
|
||||
return {
|
||||
status: 200,
|
||||
body: {}
|
||||
};
|
||||
} else {
|
||||
console.log(latestVersion);
|
||||
await asyncSleep(2000);
|
||||
return {
|
||||
status: 200,
|
||||
|
Reference in New Issue
Block a user