2024-02-19 12:03:51 -05:00
|
|
|
import { spawn, exec } from 'child_process';
|
|
|
|
|
|
|
|
|
|
export default async () => {
|
|
|
|
|
let _resolve: () => unknown;
|
2024-02-28 04:21:31 -05:00
|
|
|
const ready = new Promise<void>((resolve) => (_resolve = resolve));
|
2024-02-19 12:03:51 -05:00
|
|
|
|
|
|
|
|
const child = spawn('docker', ['compose', 'up'], { stdio: 'pipe' });
|
|
|
|
|
|
|
|
|
|
child.stdout.on('data', (data) => {
|
|
|
|
|
const input = data.toString();
|
|
|
|
|
console.log(input);
|
2024-02-28 04:21:31 -05:00
|
|
|
if (input.includes('Immich Microservices is listening')) {
|
2024-02-19 12:03:51 -05:00
|
|
|
_resolve();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
child.stderr.on('data', (data) => console.log(data.toString()));
|
|
|
|
|
|
2024-02-28 04:21:31 -05:00
|
|
|
await ready;
|
2024-02-19 12:03:51 -05:00
|
|
|
|
|
|
|
|
return async () => {
|
|
|
|
|
await new Promise<void>((resolve) =>
|
2024-02-28 04:21:31 -05:00
|
|
|
exec('docker compose down', () => resolve()),
|
2024-02-19 12:03:51 -05:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
};
|