Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

impress

Package Overview
Dependencies
Maintainers
4
Versions
719
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

impress - npm Package Compare versions

Comparing version 3.0.0-alpha.8 to 3.0.0-alpha.9

7

CHANGELOG.md

@@ -5,2 +5,6 @@ # Changelog

## [3.0.0-alpha.9][] - 2023-02-13
- Do not add `./application` to paths from `.applications`
## [3.0.0-alpha.8][] - 2023-02-04

@@ -314,3 +318,4 @@

[unreleased]: https://github.com/metarhia/impress/compare/v3.0.0-alpha.8...HEAD
[unreleased]: https://github.com/metarhia/impress/compare/v3.0.0-alpha.9...HEAD
[3.0.0-alpha.9]: https://github.com/metarhia/impress/compare/v3.0.0-alpha.8...v3.0.0-alpha.9
[3.0.0-alpha.8]: https://github.com/metarhia/impress/compare/v3.0.0-alpha.7...v3.0.0-alpha.8

@@ -317,0 +322,0 @@ [3.0.0-alpha.7]: https://github.com/metarhia/impress/compare/v3.0.0-alpha.6...v3.0.0-alpha.7

91

impress.js

@@ -18,3 +18,2 @@ 'use strict';

const WORKER_PATH = path.join(__dirname, 'lib/worker.js');
const CFG_PATH = path.join(PATH, 'application/config');
const LOG_PATH = path.join(PATH, 'log');

@@ -53,8 +52,4 @@ const CTRL_C = 3;

process.on('uncaughtException', logError('Uncaught exception'));
process.on('warning', logError('Warning'));
process.on('unhandledRejection', logError('Unhandled rejection'));
const startWorker = async (app, kind, port, id = ++impress.lastWorkerId) => {
const workerData = { id, kind, path: app.path, port };
const workerData = { id, kind, root: app.root, path: app.path, port };
const options = { trackUnmanagedFds: true, workerData };

@@ -137,16 +132,27 @@ const worker = new Worker(WORKER_PATH, options);

const loadApplication = async (root) => {
impress.console.info(`Start: ${root}`);
const configPath = path.join(root, 'application/config');
const loadApplication = async (root, dir, master) => {
impress.console.info(`Start: ${dir}`);
const configPath = path.join(dir, 'config');
const config = await new Config(configPath, CFG_OPTIONS).catch((err) => {
exit(`Can not read configuration: ${CFG_PATH}\n${err.stack}`);
exit(`Can not read configuration: ${configPath}\n${err.stack}`);
});
await validateConfig(config);
if (master) {
impress.startTimer = setTimeout(
logError('Initialization timeout'),
config.server.timeouts.start,
);
const logger = await new Logger({ ...LOG_OPTIONS, ...config.log });
logger.on('error', logError('Logger'));
if (logger.active) impress.console = logger.console;
impress.logger = logger;
const tasksPath = path.join(dir, 'tasks');
const tasksConfig = config.server.scheduler;
impress.planner = await new Planner(tasksPath, tasksConfig, impress);
impress.config = config;
}
const { balancer, ports = [], workers = {} } = config.server;
const threads = new Map();
const pool = new metautil.Pool({ timeout: workers.wait });
const app = { path: root, config, threads, pool, ready: 0 };
const app = { root, path: dir, config, threads, pool, ready: 0 };
if (balancer) await startWorker(app, 'balancer', balancer);

@@ -156,4 +162,3 @@ for (const port of ports) await startWorker(app, 'server', port);

for (let i = 0; i < poolSize; i++) await startWorker(app, 'worker');
impress.applications.set(root, app);
impress.applications.set(dir, app);
};

@@ -165,11 +170,13 @@

.then((data) => data.split(/[\r\n\s]+/).filter((s) => s.length !== 0))
.catch(() => [PATH]);
.catch(() => [path.join(PATH, 'application')]);
let master = true;
for (const dir of applications) {
const location = path.isAbsolute(dir) ? dir : path.join(PATH, dir);
await loadApplication(location);
await loadApplication(PATH, location, master);
if (master) master = false;
}
};
const stopApplication = (root) => {
const app = impress.applications.get(root);
const stopApplication = (dir) => {
const app = impress.applications.get(dir);
for (const thread of app.threads.values()) {

@@ -198,34 +205,14 @@ thread.postMessage({ name: 'stop' });

(async () => {
const configPath = path.join(PATH, 'application/config');
const config = await new Config(configPath, CFG_OPTIONS).catch((err) => {
exit(`Can not read configuration: ${CFG_PATH}\n${err.stack}`);
process.on('uncaughtException', logError('Uncaught exception'));
process.on('warning', logError('Warning'));
process.on('unhandledRejection', logError('Unhandled rejection'));
process.on('SIGINT', stop);
process.on('SIGTERM', stop);
if (process.stdin.isTTY) {
process.stdin.setRawMode(true);
process.stdin.on('data', (data) => {
const key = data[0];
if (key === CTRL_C) stop();
});
await validateConfig(config);
impress.config = config;
const logger = await new Logger({ ...LOG_OPTIONS, ...config.log });
logger.on('error', logError('Logger'));
if (logger.active) impress.console = logger.console;
impress.logger = logger;
const tasksPath = path.join(PATH, 'application/tasks');
const tasksConfig = config.server.scheduler;
impress.planner = await new Planner(tasksPath, tasksConfig, impress);
process.on('SIGINT', stop);
process.on('SIGTERM', stop);
impress.startTimer = setTimeout(
logError('Initialization timeout'),
config.server.timeouts.start,
);
await loadApplications();
if (process.stdin.isTTY) {
process.stdin.setRawMode(true);
process.stdin.on('data', (data) => {
const key = data[0];
if (key === CTRL_C) stop();
});
}
})().catch(logError('Initialization'));
}
loadApplications().catch(logError('Initialization'));

@@ -8,4 +8,3 @@ 'use strict';

const wt = require('worker_threads');
const { MessageChannel, parentPort, threadId } = wt;
const workerData = wt.workerData || { path: process.cwd() };
const { MessageChannel, parentPort, threadId, workerData } = wt;
const metautil = require('metautil');

@@ -48,4 +47,4 @@ const metavm = require('metavm');

this.finalization = false;
this.root = workerData.path;
this.path = path.join(this.root, 'application');
this.root = workerData.root;
this.path = workerData.path;

@@ -52,0 +51,0 @@ this.schemas = new Schemas('schemas', this);

{
"name": "impress",
"version": "3.0.0-alpha.8",
"version": "3.0.0-alpha.9",
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Enterprise application server for Node.js",

@@ -107,5 +107,5 @@ <div align="center">

Copyright (c) 2012-2022 Metarhia contributors.
Copyright (c) 2012-2023 Metarhia contributors.
See github for full [contributors list](https://github.com/metarhia/impress/graphs/contributors).
Impress Application Server is [MIT licensed](./LICENSE).
Project coordinator: &lt;timur.shemsedinov@gmail.com&gt;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc