MMSB-MOBI / martinize-db

Other
2 stars 0 forks source link

move jmClient.start as a Singleton #68

Closed glaunay closed 11 months ago

glaunay commented 11 months ago
export default new class JMSurcouche {
    public mode: RunMode = DEFAULT_RUN_MODE;
    public id = "";
    async run(what_to_launch: SupportedScript, args: JobInputs) {
        if (this.id === "") this.id = generateSnowflake()
        args.script = SCRIPTS[what_to_launch]

        if (this.mode === 'local') {
            const venv = LOCAL_CONFIG[what_to_launch].venv
            const modules = LOCAL_CONFIG[what_to_launch].modules
            if (venv) args.exportVar = { ...args.exportVar, venv }
            if (modules) args.modules = modules

        } else {
            args.modules = SERVER_MODULES[what_to_launch]
            args.jobProfile = SLURM_PROFILES.JOB_PROFILE,
            args.sysSettingsKey = SLURM_PROFILES.SYS_SETTINGS

        } 

        logger.debug('Launch job : ' + what_to_launch + ' with mode ' + this.mode)
        // This creates a socket every time <<===========================================
        jmClient.start(JOB_MANAGER_SETTINGS.address, JOB_MANAGER_SETTINGS.port)
        //console.log( "############################ ", args)
        return await jmClient.pushFS(args)

    }
}