Skip to content

Commit

Permalink
0.0.487
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Sep 10, 2024
1 parent 73c7469 commit 634e881
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions call.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ if (options.generate) {
"MANUAL_MIGRATIONS": '0',
// "RESTORE_VOLUME_FROM_SNAPSHOT": options.last || isGitpod ? '1': '0',
// "MANUAL_MIGRATIONS": options.migrate ? '1': '0',
"MANUAL_MIGRATIONS": "1",
"MINIO_ROOT_USER": minioAccess,
"MINIO_ROOT_PASSWORD": minioSecret,
"S3_ACCESS_KEY": minioAccess,
Expand All @@ -152,6 +151,9 @@ if (options.generate) {
if (config && options.run) {
await call(config);
}
if (config && options.stop) {
_exec(`cd ${__dirname} && docker compose -p deep down`);
}
const envs = generateEnvs({ envs: { ...(config?.envs || {}) }, isDeeplinksDocker: 0 });
const envsStr = _generateAndFillEnvs({ envs, isDeeplinksDocker: 0 })

Expand All @@ -161,7 +163,7 @@ if (options.generate) {
}

if (options.last) {
_exec(`${envsStr} docker exec -it deep-links sh -c "node snapshots/last.js"`);
_exec(`${envsStr} cd ${__dirname} && docker compose -p deep stop hasura postgres && (docker exec -it deep-links sh -c "npm run snapshot:last" || true) && docker compose -p deep start hasura postgres`);
}

if (options.migrate) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deep-foundation/deeplinks",
"version": "0.0.486",
"version": "0.0.487",
"license": "Unlicense",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"start-deeplinks-docker": "docker compose pull && docker compose -p deep up -d",
"stop-deeplinks-docker": "docker compose -p deep down",
"snapshot:create": "node snapshots/create.js",
"snapshot:last": "node snapshots/last.js",
"snapshot:last": "node snapshots/last.js",
"snapshot:dump": "node snapshots/dump.js",
"warmup": "node warmup.js"
},
Expand Down
13 changes: 8 additions & 5 deletions snapshots/last.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ import { fileURLToPath } from 'url';
const require = createRequire(import.meta.url);
const { promisify } = require('util');
const { exec } = require('child_process');
const fs = require('fs');
const { promises: fs } = require('fs');
const execP = promisify(exec);
const path = require('path');

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// const _deeplinks = path.normalize(`${__dirname}/..`);
const _deeplinks = path.normalize(`${__dirname}/..`);

const last = async () => {
const last = fs.readdirSync('./snapshots').filter(file => /^-?[0-9]+$/.test(file)).pop();
const { stdout, stderr } = await execP(`cd / && tar xf snapshots/${last} --strip 1 && cp snapshots/${last}.migrate .migrate`);
const files = await fs.readdir('./snapshots');
const snapshots = files.filter(file => /^-?[0-9]+$/.test(file));
const last = snapshots[snapshots.length - 1];
console.log(`docker run -v ${_deeplinks}:/deeplinks -v deep-db-data:/data --rm --name links --entrypoint "sh" deepf/deeplinks:main -c "cd / && tar xf snapshots/${last} --strip 1 && cp snapshots/${last}.migrate .migrate"`);
const { stdout, stderr } = await execP(`docker run -v ${_deeplinks}:/deeplinks -v deep-db-data:/data --rm --name links --entrypoint "sh" deepf/deeplinks:main -c "cd / && tar xf snapshots/${last} --strip 1 && cp snapshots/${last}.migrate .migrate"`);
console.log('stdout',stdout);
console.log('stderr',stderr);
}

last();
last();

0 comments on commit 634e881

Please sign in to comment.