Skip to content

Commit

Permalink
feat(sys-server): add max_old_space_size of node vm config;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Sep 8, 2021
1 parent 8c7e852 commit 5275071
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion packages/system-server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class Config {
/**
* the logger level : 'fatal', 'error', 'warning', 'info', 'debug', 'trace'
*/
static get DB_LOG_LEVEL(): string {
static get DB_LOG_LEVEL(): string {
return process.env['DB_LOG_LEVEL'] ?? (this.isProd ? 'warning' : 'debug')
}

Expand Down Expand Up @@ -100,4 +100,12 @@ export default class Config {
static get APP_DEPLOY_URL(): string {
return process.env.APP_DEPLOY_URL ?? ''
}

/**
* The max old space size of node vm of application service, default is 256mb
* @see --max_old_space_size of node argv
*/
static get APP_SERVICE_NODE_MAX_OLD_SPACE_SIZE(): number {
return (process.env.APP_SERVICE_NODE_MAX_OLD_SPACE_SIZE ?? 256) as number
}
}
6 changes: 3 additions & 3 deletions packages/system-server/src/lib/service-driver/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export class DockerContainerServiceDriver {
*/
async createService(app: ApplicationStruct) {
const uri = getApplicationDbUri(app)

const max_old_space_size = Config.APP_SERVICE_NODE_MAX_OLD_SPACE_SIZE
const container = await this.docker.createContainer({
Image: Config.APP_SERVICE_IMAGE,
Cmd: ['node', './dist/start.js'],
Cmd: ['node', `--max_old_space_size=${max_old_space_size}`, './dist/start.js'],
name: `app_${app.appid}`,
Env: [
`DB=${app.config.db_name}`,
Expand Down Expand Up @@ -72,7 +72,7 @@ export class DockerContainerServiceDriver {
* Stop application service
* @param app
*/
async stopService(app: ApplicationStruct) {
async stopService(app: ApplicationStruct) {
const info = await this.info(app)
if (!info) {
return
Expand Down

0 comments on commit 5275071

Please sign in to comment.