misc stuff from production
(also refactors qemu a bit)
This commit is contained in:
@@ -6,7 +6,7 @@ import * as guac from '@cvmts/guac-rs';
|
||||
import CircularBuffer from 'mnemonist/circular-buffer.js';
|
||||
import Queue from 'mnemonist/queue.js';
|
||||
import { createHash } from 'crypto';
|
||||
import { QemuVM, QemuVmDefinition } from '@cvmts/qemu';
|
||||
import { VMState, QemuVM, QemuVmDefinition } from '@cvmts/qemu';
|
||||
import { IPDataManager } from './IPData.js';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
@@ -21,6 +21,10 @@ const __dirname = import.meta.dirname;
|
||||
|
||||
const kCVMTSAssetsRoot = path.resolve(__dirname, '../../assets');
|
||||
|
||||
const kRestartTimeout = 5000;
|
||||
|
||||
|
||||
|
||||
type ChatHistory = {
|
||||
user: string;
|
||||
msg: string;
|
||||
@@ -110,6 +114,19 @@ export default class CollabVMServer {
|
||||
|
||||
this.VM = vm;
|
||||
|
||||
// hack but whatever (TODO: less rickity)
|
||||
if(config.vm.type == "qemu") {
|
||||
(vm as QemuVM).on('statechange', (newState: VMState) => {
|
||||
if(newState == VMState.Stopped) {
|
||||
this.logger.Info("stopped ?");
|
||||
setTimeout(async () => {
|
||||
this.logger.Info("restarting VM");
|
||||
await this.VM.Start();
|
||||
}, kRestartTimeout)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// authentication manager
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user