mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
273299cc3c
@ -3,6 +3,8 @@ set -e
|
||||
|
||||
echo "COMMIT_HASH: $(cat /app/commit_hash.txt)"
|
||||
|
||||
export NOCOBASE_RUNNING_IN_DOCKER=true
|
||||
|
||||
if [ ! -d "/app/nocobase" ]; then
|
||||
mkdir nocobase
|
||||
fi
|
||||
|
@ -8,19 +8,30 @@
|
||||
*/
|
||||
const _ = require('lodash');
|
||||
const { Command } = require('commander');
|
||||
const { isDev, run, postCheck, downloadPro, promptForTs } = require('../util');
|
||||
const { run, postCheck, downloadPro, promptForTs } = require('../util');
|
||||
const { existsSync, rmSync } = require('fs');
|
||||
const { resolve } = require('path');
|
||||
const { resolve, isAbsolute } = require('path');
|
||||
const chalk = require('chalk');
|
||||
const chokidar = require('chokidar');
|
||||
|
||||
function getSocketPath() {
|
||||
const { SOCKET_PATH } = process.env;
|
||||
|
||||
if (isAbsolute(SOCKET_PATH)) {
|
||||
return SOCKET_PATH;
|
||||
}
|
||||
|
||||
return resolve(process.cwd(), SOCKET_PATH);
|
||||
}
|
||||
|
||||
function deleteSockFiles() {
|
||||
const { SOCKET_PATH, PM2_HOME } = process.env;
|
||||
const { PM2_HOME } = process.env;
|
||||
if (existsSync(PM2_HOME)) {
|
||||
rmSync(PM2_HOME, { recursive: true });
|
||||
}
|
||||
if (existsSync(SOCKET_PATH)) {
|
||||
rmSync(SOCKET_PATH);
|
||||
const socketPath = getSocketPath();
|
||||
if (existsSync(socketPath)) {
|
||||
rmSync(socketPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,12 @@ const net = require('net');
|
||||
const chalk = require('chalk');
|
||||
const execa = require('execa');
|
||||
const fg = require('fast-glob');
|
||||
const { dirname, join, resolve, sep } = require('path');
|
||||
const { dirname, join, resolve, sep, isAbsolute } = require('path');
|
||||
const { readFile, writeFile } = require('fs').promises;
|
||||
const { existsSync, mkdirSync, cpSync, writeFileSync } = require('fs');
|
||||
const dotenv = require('dotenv');
|
||||
const fs = require('fs');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
const moment = require('moment-timezone');
|
||||
|
||||
exports.isPackageValid = (pkg) => {
|
||||
@ -325,6 +326,32 @@ function areTimeZonesEqual(timeZone1, timeZone2) {
|
||||
return moment.tz(timeZone1).format('Z') === moment.tz(timeZone2).format('Z');
|
||||
}
|
||||
|
||||
function generateGatewayPath() {
|
||||
if (process.env.SOCKET_PATH) {
|
||||
if (isAbsolute(process.env.SOCKET_PATH)) {
|
||||
return process.env.SOCKET_PATH;
|
||||
}
|
||||
return resolve(process.cwd(), process.env.SOCKET_PATH);
|
||||
}
|
||||
if (process.env.NOCOBASE_RUNNING_IN_DOCKER === 'true') {
|
||||
return resolve(os.homedir(), '.nocobase', 'gateway.sock');
|
||||
}
|
||||
return resolve(process.cwd(), 'storage/gateway.sock');
|
||||
}
|
||||
|
||||
function generatePm2Home() {
|
||||
if (process.env.PM2_HOME) {
|
||||
if (isAbsolute(process.env.PM2_HOME)) {
|
||||
return process.env.PM2_HOME;
|
||||
}
|
||||
return resolve(process.cwd(), process.env.PM2_HOME);
|
||||
}
|
||||
if (process.env.NOCOBASE_RUNNING_IN_DOCKER === 'true') {
|
||||
return resolve(os.homedir(), '.nocobase', 'pm2');
|
||||
}
|
||||
return resolve(process.cwd(), './storage/.pm2');
|
||||
}
|
||||
|
||||
exports.initEnv = function initEnv() {
|
||||
const env = {
|
||||
APP_ENV: 'development',
|
||||
@ -343,9 +370,9 @@ exports.initEnv = function initEnv() {
|
||||
MFSU_AD: 'none',
|
||||
MAKO_AD: 'none',
|
||||
WS_PATH: '/ws',
|
||||
SOCKET_PATH: 'storage/gateway.sock',
|
||||
// PM2_HOME: generatePm2Home(),
|
||||
// SOCKET_PATH: generateGatewayPath(),
|
||||
NODE_MODULES_PATH: resolve(process.cwd(), 'node_modules'),
|
||||
PM2_HOME: resolve(process.cwd(), './storage/.pm2'),
|
||||
PLUGIN_PACKAGE_PREFIX: '@nocobase/plugin-,@nocobase/plugin-sample-,@nocobase/preset-',
|
||||
SERVER_TSCONFIG_PATH: './tsconfig.server.json',
|
||||
PLAYWRIGHT_AUTH_FILE: resolve(process.cwd(), 'storage/playwright/.auth/admin.json'),
|
||||
@ -428,6 +455,11 @@ exports.initEnv = function initEnv() {
|
||||
`process.env.DB_TIMEZONE="${process.env.DB_TIMEZONE}" and process.env.TZ="${process.env.TZ}" are different`,
|
||||
);
|
||||
}
|
||||
|
||||
process.env.PM2_HOME = generatePm2Home();
|
||||
process.env.SOCKET_PATH = generateGatewayPath();
|
||||
fs.mkdirpSync(dirname(process.env.SOCKET_PATH), { force: true, recursive: true });
|
||||
fs.mkdirpSync(process.env.PM2_HOME, { force: true, recursive: true });
|
||||
};
|
||||
|
||||
exports.generatePlugins = function () {
|
||||
|
@ -18,7 +18,7 @@ import fs from 'fs';
|
||||
import http, { IncomingMessage, ServerResponse } from 'http';
|
||||
import compose from 'koa-compose';
|
||||
import { promisify } from 'node:util';
|
||||
import { resolve } from 'path';
|
||||
import { isAbsolute, resolve } from 'path';
|
||||
import qs from 'qs';
|
||||
import handler from 'serve-handler';
|
||||
import { parse } from 'url';
|
||||
@ -57,6 +57,16 @@ export interface AppSelectorMiddlewareContext {
|
||||
resolvedAppName: string | null;
|
||||
}
|
||||
|
||||
function getSocketPath() {
|
||||
const { SOCKET_PATH } = process.env;
|
||||
|
||||
if (isAbsolute(SOCKET_PATH)) {
|
||||
return SOCKET_PATH;
|
||||
}
|
||||
|
||||
return resolve(process.cwd(), SOCKET_PATH);
|
||||
}
|
||||
|
||||
export class Gateway extends EventEmitter {
|
||||
private static instance: Gateway;
|
||||
/**
|
||||
@ -75,9 +85,7 @@ export class Gateway extends EventEmitter {
|
||||
private constructor() {
|
||||
super();
|
||||
this.reset();
|
||||
if (process.env.SOCKET_PATH) {
|
||||
this.socketPath = resolve(process.cwd(), process.env.SOCKET_PATH);
|
||||
}
|
||||
this.socketPath = getSocketPath();
|
||||
}
|
||||
|
||||
public static getInstance(options: any = {}): Gateway {
|
||||
@ -89,7 +97,7 @@ export class Gateway extends EventEmitter {
|
||||
}
|
||||
|
||||
static async getIPCSocketClient() {
|
||||
const socketPath = resolve(process.cwd(), process.env.SOCKET_PATH || 'storage/gateway.sock');
|
||||
const socketPath = getSocketPath();
|
||||
try {
|
||||
return await IPCSocketClient.getConnection(socketPath);
|
||||
} catch (error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user