vona-core 5.0.107 → 5.0.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +57 -42
- package/dist/lib/decorator/type/index.d.ts +1 -0
- package/dist/lib/decorator/type/string.d.ts +1 -0
- package/dist/lib/framework/cluster.d.ts +1 -0
- package/dist/lib/framework/index.d.ts +0 -1
- package/dist/lib/framework/processMaster.d.ts +1 -0
- package/dist/lib/framework/processWorker.d.ts +1 -0
- package/package.json +1 -1
- package/dist/lib/framework/process.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -2966,8 +2966,45 @@ function prepareAppInfo(env) {
|
|
|
2966
2966
|
};
|
|
2967
2967
|
}
|
|
2968
2968
|
|
|
2969
|
-
let
|
|
2970
|
-
|
|
2969
|
+
let __closing$1 = false;
|
|
2970
|
+
let __timeout;
|
|
2971
|
+
async function _closeInner$1() {
|
|
2972
|
+
__timeout = setTimeout(() => {
|
|
2973
|
+
// eslint-disable-next-line no-console
|
|
2974
|
+
console.log('Cleanup timed out. Forcing termination...');
|
|
2975
|
+
process.exit(1);
|
|
2976
|
+
}, 5000);
|
|
2977
|
+
}
|
|
2978
|
+
function handleProcessMaster(workers) {
|
|
2979
|
+
['SIGINT', 'SIGUSR2'].forEach(signal => {
|
|
2980
|
+
process.on(signal, async () => {
|
|
2981
|
+
if (__closing$1) return;
|
|
2982
|
+
__closing$1 = true;
|
|
2983
|
+
await _closeInner$1();
|
|
2984
|
+
});
|
|
2985
|
+
});
|
|
2986
|
+
for (let i = 0; i < workers; i++) {
|
|
2987
|
+
cluster.fork();
|
|
2988
|
+
}
|
|
2989
|
+
cluster.on('message', (worker, message) => {
|
|
2990
|
+
if (message === 'reload-worker') {
|
|
2991
|
+
if (!__closing$1) {
|
|
2992
|
+
cluster.fork();
|
|
2993
|
+
}
|
|
2994
|
+
worker.process.kill('SIGTERM');
|
|
2995
|
+
}
|
|
2996
|
+
});
|
|
2997
|
+
cluster.on('exit', (_worker, _code, _signal) => {
|
|
2998
|
+
// console.log(`----------------- worker ${_worker.process.pid} died`, _code, _signal);
|
|
2999
|
+
if (cluster.workers && Object.keys(cluster.workers).length === 0) {
|
|
3000
|
+
clearTimeout(__timeout);
|
|
3001
|
+
process.exit(0);
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
let __closing = false;
|
|
3007
|
+
async function _closeInner() {
|
|
2971
3008
|
const timeout = setTimeout(() => {
|
|
2972
3009
|
// eslint-disable-next-line no-console
|
|
2973
3010
|
console.log('Cleanup timed out. Forcing termination...');
|
|
@@ -2983,15 +3020,12 @@ async function _closeAppInner() {
|
|
|
2983
3020
|
process.exit(err ? 1 : 0);
|
|
2984
3021
|
}
|
|
2985
3022
|
function handleProcessWork() {
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
process.on('SIGUSR2', async () => {
|
|
2993
|
-
// console.log('------------SIGUSR2');
|
|
2994
|
-
await _closeAppInner();
|
|
3023
|
+
['SIGINT', 'SIGUSR2'].forEach(signal => {
|
|
3024
|
+
process.on(signal, async () => {
|
|
3025
|
+
if (__closing) return;
|
|
3026
|
+
__closing = true;
|
|
3027
|
+
await _closeInner();
|
|
3028
|
+
});
|
|
2995
3029
|
});
|
|
2996
3030
|
process.on('uncaughtException', async err => {
|
|
2997
3031
|
const app = useApp();
|
|
@@ -3014,48 +3048,29 @@ function handleProcessWork() {
|
|
|
3014
3048
|
}
|
|
3015
3049
|
});
|
|
3016
3050
|
}
|
|
3017
|
-
function handleProcessMaster() {
|
|
3018
|
-
process.on('SIGINT', () => {
|
|
3019
|
-
// donothing
|
|
3020
|
-
});
|
|
3021
|
-
process.on('SIGUSR2', () => {
|
|
3022
|
-
// donothing
|
|
3023
|
-
});
|
|
3024
|
-
}
|
|
3025
3051
|
|
|
3026
3052
|
async function startCluster(workers, bootstrapOptions) {
|
|
3027
3053
|
if (cluster.isPrimary) {
|
|
3028
|
-
handleProcessMaster();
|
|
3054
|
+
handleProcessMaster(workers);
|
|
3029
3055
|
createAppMaster(bootstrapOptions);
|
|
3030
|
-
for (let i = 0; i < workers; i++) {
|
|
3031
|
-
cluster.fork();
|
|
3032
|
-
}
|
|
3033
|
-
cluster.on('message', (worker, message) => {
|
|
3034
|
-
if (message === 'reload-worker') {
|
|
3035
|
-
cluster.fork();
|
|
3036
|
-
worker.process.kill('SIGTERM');
|
|
3037
|
-
}
|
|
3038
|
-
});
|
|
3039
|
-
cluster.on('exit', (_worker, _code, _signal) => {
|
|
3040
|
-
// console.log(`----------------- worker ${_worker.process.pid} died`, _code, _signal);
|
|
3041
|
-
if (cluster.workers && Object.keys(cluster.workers).length === 0) {
|
|
3042
|
-
process.exit(0);
|
|
3043
|
-
}
|
|
3044
|
-
});
|
|
3045
3056
|
} else {
|
|
3046
|
-
|
|
3047
|
-
await createApp(bootstrapOptions);
|
|
3057
|
+
await startWorker(bootstrapOptions);
|
|
3048
3058
|
}
|
|
3049
3059
|
}
|
|
3060
|
+
async function startWorker(bootstrapOptions) {
|
|
3061
|
+
handleProcessWork();
|
|
3062
|
+
return await createApp(bootstrapOptions);
|
|
3063
|
+
}
|
|
3050
3064
|
|
|
3051
3065
|
async function bootstrap(bootstrapOptions) {
|
|
3052
3066
|
const env = prepareEnv(bootstrapOptions.env);
|
|
3053
3067
|
const workers = Number.parseInt(env.SERVER_WORKERS);
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3068
|
+
const alwaysCluster = process.env.META_MODE === 'dev' || process.platform.startsWith('win');
|
|
3069
|
+
if (workers > 1 || alwaysCluster) {
|
|
3070
|
+
await startCluster(workers, bootstrapOptions);
|
|
3071
|
+
} else {
|
|
3072
|
+
return await startWorker(bootstrapOptions);
|
|
3057
3073
|
}
|
|
3058
|
-
await startCluster(workers, bootstrapOptions);
|
|
3059
3074
|
}
|
|
3060
3075
|
|
|
3061
3076
|
function ExtendClass(classRef) {
|
|
@@ -3201,4 +3216,4 @@ function prepareNativeBinding(nativeBinding) {
|
|
|
3201
3216
|
|
|
3202
3217
|
zodExtendOpenApi();
|
|
3203
3218
|
|
|
3204
|
-
export { $Class, $customKey, $localeScope, AppHmr, AppHmrDeps, AppLocale, AppLogger, AppMeta, AppMetadata, AppResource, AppUtil, BeanAopBase, BeanAopMethodBase, BeanBase, BeanBaseSimple, BeanContainer, BeanInfo, BeanScopeBase, BeanScopeContainer, BeanScopeError, BeanScopeErrorImpl, BeanScopeLocale, BeanScopeScene, BeanScopeUtil, BeanSimple, EnumAppEvent, ErrorClass, LocaleModuleNameSeparator, PickClassInner, ProxyDisable, SymbolBeanContainerInstances, SymbolBeanFullName, SymbolBeanInstanceKey, SymbolBeanInstancePropsLazy, SymbolCacheAopChains, SymbolCacheAopChainsKey, SymbolDecoratorBeanFullName, SymbolDecoratorBeanInfo, SymbolDecoratorProxyDisable, SymbolDecoratorUse, SymbolDecoratorVirtual, SymbolHmrStateLoad, SymbolHmrStateSave, SymbolMappedClassMetadataKeys, SymbolModuleBelong, SymbolModuleName, Use, Virtual, VonaApplication, __prepareInjectSelectorInfo, appHmrDeps, appMetadata, appResource, beanFullNameFromOnionName, bootstrap, cast, closeApp, combineConfigDefault, combineFilePathSafe, compose, copyMetadataOfClasses, copyProperties, copyPropertiesOfClasses, copySqlite3NativeBinding, createApp, createAppMaster, createBeanDecorator, createGeneralApp, createHash, deepExtend, disposeInstance, errorsInternal, filterHeaders, formatLoggerAxiosError, formatLoggerConsole, formatLoggerCtx, formatLoggerDummy, formatLoggerFilter, functionNoop, getLoggerPathPhysicalRoot, getMappedClassMetadataKeys, getPublicPathPhysicalRoot, getRuntimePathPhysicalRoot, getSqlite3DatabaseNameDefault, getSqlite3NativeBinding,
|
|
3219
|
+
export { $Class, $customKey, $localeScope, AppHmr, AppHmrDeps, AppLocale, AppLogger, AppMeta, AppMetadata, AppResource, AppUtil, BeanAopBase, BeanAopMethodBase, BeanBase, BeanBaseSimple, BeanContainer, BeanInfo, BeanScopeBase, BeanScopeContainer, BeanScopeError, BeanScopeErrorImpl, BeanScopeLocale, BeanScopeScene, BeanScopeUtil, BeanSimple, EnumAppEvent, ErrorClass, LocaleModuleNameSeparator, PickClassInner, ProxyDisable, SymbolBeanContainerInstances, SymbolBeanFullName, SymbolBeanInstanceKey, SymbolBeanInstancePropsLazy, SymbolCacheAopChains, SymbolCacheAopChainsKey, SymbolDecoratorBeanFullName, SymbolDecoratorBeanInfo, SymbolDecoratorProxyDisable, SymbolDecoratorUse, SymbolDecoratorVirtual, SymbolHmrStateLoad, SymbolHmrStateSave, SymbolMappedClassMetadataKeys, SymbolModuleBelong, SymbolModuleName, Use, Virtual, VonaApplication, __prepareInjectSelectorInfo, appHmrDeps, appMetadata, appResource, beanFullNameFromOnionName, bootstrap, cast, closeApp, combineConfigDefault, combineFilePathSafe, compose, copyMetadataOfClasses, copyProperties, copyPropertiesOfClasses, copySqlite3NativeBinding, createApp, createAppMaster, createBeanDecorator, createGeneralApp, createHash, deepExtend, disposeInstance, errorsInternal, filterHeaders, formatLoggerAxiosError, formatLoggerConsole, formatLoggerCtx, formatLoggerDummy, formatLoggerFilter, functionNoop, getLoggerPathPhysicalRoot, getMappedClassMetadataKeys, getPublicPathPhysicalRoot, getRuntimePathPhysicalRoot, getSqlite3DatabaseNameDefault, getSqlite3NativeBinding, instanceDesp, loadJSONFile, localeDefault, onionNameFromBeanFullName, pathToHref, polyfillDispose, prepareEnv, registerMappedClassMetadataKey, requireDynamic, retry, saveJSONFile, setMappedClassMetadataKeys, useApp, usePrepareArg, usePrepareArgs, uuidv4 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type PickString<T> = T extends string ? T : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function handleProcessMaster(workers: number): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function handleProcessWork(): void;
|
package/package.json
CHANGED