27 lines
899 B
TypeScript
27 lines
899 B
TypeScript
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
|
import * as tspm from '../ts/index.js';
|
|
|
|
tap.test('first test', async () => {
|
|
console.log(tspm);
|
|
});
|
|
|
|
tap.start();
|
|
|
|
// Example usage:
|
|
const config: tspm.IMonitorConfig = {
|
|
name: 'Project XYZ Monitor', // Identifier for the instance
|
|
projectDir: '/path/to/your/project', // Set the project directory here
|
|
command: 'npm run xyz', // Full command string (no need for args)
|
|
memoryLimitBytes: 500 * 1024 * 1024, // 500 MB memory limit
|
|
monitorIntervalMs: 5000, // Check memory usage every 5 seconds
|
|
};
|
|
|
|
const monitor = new tspm.ProcessMonitor(config);
|
|
monitor.start();
|
|
|
|
// Ensure that on process exit (e.g. Ctrl+C) we clean up the child process and prevent respawns.
|
|
process.on('SIGINT', () => {
|
|
console.log('Received SIGINT, stopping monitor...');
|
|
monitor.stop();
|
|
process.exit();
|
|
}); |