befly 3.71.0 → 3.72.0
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/index.js +1 -1
- package/package.json +1 -1
- package/plugins/cron.js +2 -2
- package/utils/is.js +3 -2
package/index.js
CHANGED
|
@@ -177,7 +177,7 @@ export class Befly {
|
|
|
177
177
|
await ensureSyncPrerequisites(this.context);
|
|
178
178
|
|
|
179
179
|
// 自动同步(PM2 cluster:主进程执行,其它进程等待同步完成)
|
|
180
|
-
if (isPrimaryProcess(
|
|
180
|
+
if (isPrimaryProcess()) {
|
|
181
181
|
await syncApi(this.context, this.apis);
|
|
182
182
|
await syncMenu(this.context, this.menus);
|
|
183
183
|
await syncDev(this.context);
|
package/package.json
CHANGED
package/plugins/cron.js
CHANGED
|
@@ -16,7 +16,7 @@ const jobs = new Map();
|
|
|
16
16
|
* @returns {CronJob|null}
|
|
17
17
|
*/
|
|
18
18
|
function register(context, name, schedule, task) {
|
|
19
|
-
if (!isPrimaryProcess(
|
|
19
|
+
if (!isPrimaryProcess()) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -42,7 +42,7 @@ function register(context, name, schedule, task) {
|
|
|
42
42
|
* 注册一个按秒执行的定时任务
|
|
43
43
|
*/
|
|
44
44
|
function second(context, name, seconds, task) {
|
|
45
|
-
if (!isPrimaryProcess(
|
|
45
|
+
if (!isPrimaryProcess()) {
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
48
|
|
package/utils/is.js
CHANGED
|
@@ -349,8 +349,9 @@ export function isEmpty(value) {
|
|
|
349
349
|
* 判断当前进程是否为主进程。
|
|
350
350
|
* PM2 cluster 的实例 0 是主进程;未由 PM2 启动时视为主进程。
|
|
351
351
|
*/
|
|
352
|
-
export function isPrimaryProcess(
|
|
353
|
-
|
|
352
|
+
export function isPrimaryProcess() {
|
|
353
|
+
const instance = Bun.env.NODE_APP_INSTANCE;
|
|
354
|
+
return instance === "0" || instance === 0 || instance === undefined;
|
|
354
355
|
}
|
|
355
356
|
|
|
356
357
|
export const isDirentDirectory = (parentDir, entry) => {
|