56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import * as plugins from './coretraffic.plugins.js';
|
|
import * as paths from './coretraffic.paths.js'
|
|
import { logger } from './coretraffic.logging.js';
|
|
import { CoreflowConnector } from './coretraffic.classes.coreflowconnector.js';
|
|
import { CoretrafficTaskManager } from './coretraffic.classes.taskmanager.js';
|
|
|
|
export interface ICoretrafficConfig {
|
|
dockerDomainEnvName?: string;
|
|
}
|
|
|
|
export class CoreTraffic {
|
|
public projectinfo = new plugins.projectinfo.ProjectinfoNpm(paths.packageDir);
|
|
public typedrouter = new plugins.typedrequest.TypedRouter();
|
|
public coreflowConnector: CoreflowConnector;
|
|
public taskmanager: CoretrafficTaskManager;
|
|
public networkProxy: plugins.smartproxy.NetworkProxy;
|
|
public sslRedirect: plugins.smartproxy.SslRedirect;
|
|
|
|
constructor() {
|
|
this.coreflowConnector = new CoreflowConnector(this);
|
|
this.taskmanager = new CoretrafficTaskManager(this);
|
|
this.networkProxy = new plugins.smartproxy.NetworkProxy({
|
|
port: 8000
|
|
});
|
|
this.sslRedirect = new plugins.smartproxy.SslRedirect(7999);
|
|
}
|
|
|
|
/**
|
|
* starts coretraffic
|
|
*/
|
|
public async start() {
|
|
await this.networkProxy.start();
|
|
await this.sslRedirect.start();
|
|
this.networkProxy.addDefaultHeaders({
|
|
servezone_coretraffic_version: this.projectinfo.version
|
|
})
|
|
|
|
await this.taskmanager.start();
|
|
await this.coreflowConnector.start();
|
|
}
|
|
|
|
/**
|
|
* stops coretraffic
|
|
*/
|
|
public async stop() {
|
|
await this.taskmanager.stop();
|
|
console.log('stopped taskmanager');
|
|
await this.coreflowConnector.stop();
|
|
console.log('stopped coreflowConnector');
|
|
await this.networkProxy.stop();
|
|
console.log('stopped smartproxy!');
|
|
await this.sslRedirect.stop();
|
|
|
|
}
|
|
}
|