Compare commits
1 commit
develop
...
stream-ins
Author | SHA1 | Date | |
---|---|---|---|
|
e40ffd121d |
3 changed files with 14 additions and 5 deletions
|
@ -103,7 +103,10 @@ const installApp = async (req: Request, res: Response, next: NextFunction) => {
|
|||
throw new Error('App name is required');
|
||||
}
|
||||
|
||||
await AppsService.installApp(id, form);
|
||||
await AppsService.installApp(id, form, (data: string) => {
|
||||
console.log('Stream:', data);
|
||||
res.write(data);
|
||||
});
|
||||
|
||||
res.status(200).json({ message: 'App installed successfully' });
|
||||
} catch (e) {
|
||||
|
|
|
@ -75,15 +75,21 @@ export const checkAppExists = (appName: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const runAppScript = (params: string[]): Promise<void> => {
|
||||
export const runAppScript = (params: string[], processClbk?: (data: string) => void): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
runScript('/scripts/app.sh', [...params, config.ROOT_FOLDER_HOST], (err: string) => {
|
||||
const process = runScript('/scripts/app.sh', [...params, config.ROOT_FOLDER_HOST], (err: string) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
|
||||
if (processClbk) {
|
||||
process.stdout?.on('data', (data: string) => {
|
||||
processClbk?.(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ const startApp = async (appName: string): Promise<void> => {
|
|||
ensureAppState(appName, true);
|
||||
};
|
||||
|
||||
const installApp = async (id: string, form: Record<string, string>): Promise<void> => {
|
||||
const installApp = async (id: string, form: Record<string, string>, stdout?: (data: string) => void): Promise<void> => {
|
||||
const appExists = fileExists(`/app-data/${id}`);
|
||||
|
||||
if (appExists) {
|
||||
|
@ -37,7 +37,7 @@ const installApp = async (id: string, form: Record<string, string>): Promise<voi
|
|||
ensureAppState(id, true);
|
||||
|
||||
// Run script
|
||||
await runAppScript(['install', id]);
|
||||
await runAppScript(['install', id], stdout);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
|
|
Loading…
Reference in a new issue