Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "eslint-config-egg",
"parserOptions": {
"ecmaVersion": 13
}
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
24 changes: 0 additions & 24 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest'
version: '14, 16, 18, 20, 22'
version: '18.19.0, 18, 20, 22, 23'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish Any Commit
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm install

- name: Build
run: npm run prepublishOnly --if-present

- run: npx pkg-pr-new publish
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ run
.nyc_output
package-lock.json
.package-lock.json
.tshy*
.eslintcache
dist
coverage
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
# Changelog

## [3.0.1](https://github.com/eggjs/cluster/compare/v3.0.0...v3.0.1) (2024-12-30)


### Bug Fixes

* require support paths ([#118](https://github.com/eggjs/cluster/issues/118)) ([b74872c](https://github.com/eggjs/cluster/commit/b74872c1625e7a6c3ee58a3cc468fdae43a9b000))

## [3.0.0](https://github.com/eggjs/cluster/compare/v2.4.0...v3.0.0) (2024-12-28)


### ⚠ BREAKING CHANGES

* drop Node.js < 18.19.0 support

part of https://github.com/eggjs/egg/issues/3644

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes for @eggjs/cluster v3.0.0-beta.4

- **New Features**
- Migrated project to TypeScript.
- Added support for Node.js 18.19.0, 20, 22, and 23.
- Enhanced type safety and module exports.
- Improved worker thread and process management.
- Introduced new error handling classes for better debugging.

- **Breaking Changes**
- Renamed package from `egg-cluster` to `@eggjs/cluster`.
- Updated import/export syntax to ES modules.
- Minimum Node.js version is now 18.19.0.

- **Performance Improvements**
- Refactored cluster and worker management.
- Optimized error handling and logging.

- **Bug Fixes**
- Resolved various edge cases in worker initialization.
- Improved graceful shutdown mechanisms.

- **Documentation**
- Updated README with new package name and usage examples.
- Added TypeScript and ESM import examples.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Comment on lines +21 to +48
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Trim the auto-generated summary block from the changelog.

This section is very verbose and includes beta-oriented wording inside final release notes, which can make the changelog harder to trust/scan.

Suggested cleanup
-## Summary by CodeRabbit
-
-## Release Notes for `@eggjs/cluster` v3.0.0-beta.4
-
-- **New Features**
-  - Migrated project to TypeScript.
-  - Added support for Node.js 18.19.0, 20, 22, and 23.
-  - Enhanced type safety and module exports.
-  - Improved worker thread and process management.
-  - Introduced new error handling classes for better debugging.
-
-- **Breaking Changes**
-  - Renamed package from `egg-cluster` to `@eggjs/cluster`.
-  - Updated import/export syntax to ES modules.
-  - Minimum Node.js version is now 18.19.0.
-
-- **Performance Improvements**
-  - Refactored cluster and worker management.
-  - Optimized error handling and logging.
-
-- **Bug Fixes**
-  - Resolved various edge cases in worker initialization.
-  - Improved graceful shutdown mechanisms.
-
-- **Documentation**
-  - Updated README with new package name and usage examples.
-  - Added TypeScript and ESM import examples.
🧰 Tools
🪛 LanguageTool

[grammar] ~30-~30: Use a hyphen to join words.
Context: ...ess management. - Introduced new error handling classes for better debugging. ...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 21 - 48, Remove the auto-generated "## Summary by
CodeRabbit" block and the verbose beta-oriented release notes beneath it (the
section starting with "## Release Notes for `@eggjs/cluster` v3.0.0-beta.4"
through the closing auto-generated comment), and replace it with a concise,
final-release changelog entry that omits beta wording and redundant bullets;
locate the block by the header "## Summary by CodeRabbit" and the subsection
title "Release Notes for `@eggjs/cluster` v3.0.0-beta.4" and trim or rewrite those
lines to a short, trustable summary.


### Features

* support cjs and esm both by tshy ([#117](https://github.com/eggjs/cluster/issues/117)) ([e15a4bf](https://github.com/eggjs/cluster/commit/e15a4bf45682609f9362eef485e9fc87d916d2a0))

## [2.4.0](https://github.com/eggjs/egg-cluster/compare/v2.3.0...v2.4.0) (2024-12-09)


Expand Down
50 changes: 32 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,62 @@
# egg-cluster

[![NPM version][npm-image]][npm-url]
[![CI](https://github.com/eggjs/egg-cluster/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-cluster/actions/workflows/nodejs.yml)
[![CI](https://github.com/eggjs/cluster/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/cluster/actions/workflows/nodejs.yml)
[![Test coverage][codecov-image]][codecov-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[![Node.js Version](https://img.shields.io/node/v/@eggjs/cluster.svg?style=flat)](https://nodejs.org/en/download/)

[npm-image]: https://img.shields.io/npm/v/egg-cluster.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-cluster
[codecov-image]: https://codecov.io/github/eggjs/egg-cluster/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/eggjs/egg-cluster?branch=master
[snyk-image]: https://snyk.io/test/npm/egg-cluster/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-cluster
[download-image]: https://img.shields.io/npm/dm/egg-cluster.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-cluster
[npm-image]: https://img.shields.io/npm/v/@eggjs/cluster.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@eggjs/cluster
[codecov-image]: https://codecov.io/github/eggjs/cluster/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/eggjs/cluster?branch=master
[snyk-image]: https://snyk.io/test/npm/@eggjs/cluster/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/@eggjs/cluster
[download-image]: https://img.shields.io/npm/dm/@eggjs/cluster.svg?style=flat-square
[download-url]: https://npmjs.org/package/@eggjs/cluster

Cluster Manager for EggJS

---

## Install

```bash
npm i egg-cluster --save
npm i @eggjs/cluster
```

## Usage

CommonJS

```js
const startCluster = require('egg-cluster').startCluster;
const { startCluster } = require('@eggjs/cluster');

startCluster({
baseDir: '/path/to/app',
framework: '/path/to/framework',
});
```

You can specify a callback that will be invoked when application has started. However, master process will exit when catch an error.
You can specify a callback that will be invoked when application has started.
However, master process will exit when catch an error.
Comment on lines +40 to +41
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify Promise wording in startup description.

Current text says “callback” and has awkward grammar; this section reads clearer if it explicitly describes Promise-based completion/error handling.

Suggested wording
-You can specify a callback that will be invoked when application has started.
-However, master process will exit when catch an error.
+You can handle startup completion from the returned Promise.
+The master process exits if startup throws an error.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
You can specify a callback that will be invoked when application has started.
However, master process will exit when catch an error.
You can handle startup completion from the returned Promise.
The master process exits if startup throws an error.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 40 - 41, The README’s startup section uses “callback”
and awkward grammar (“when application has started”, “will exit when catch an
error”); change it to explicit Promise-based wording that is grammatically
correct and clear. Replace references to a “callback” with a Promise-based
description such as: the startup function returns a Promise that resolves when
the application has started and rejects if startup fails; update the sentence
“master process will exit when catch an error” to something like “the master
process will exit if the Promise rejects due to a startup error,” and ensure
examples and verbs are present-tense and grammatically correct.


```js
startCluster(options, () => {
startCluster(options).then(() => {
console.log('started');
});
```

ESM and TypeScript

```ts
import { startCluster } from '@eggjs/cluster';

startCluster({
baseDir: '/path/to/app',
framework: '/path/to/framework',
});
```

## Options

| Param | Type | Description |
Expand All @@ -63,16 +77,16 @@ startCluster(options, () => {

## Env

EGG_APP_CLOSE_TIMEOUT: app worker boot timeout value
`EGG_APP_CLOSE_TIMEOUT`: app worker boot timeout value

EGG_AGENT_CLOSE_TIMEOUT: agent worker boot timeout value
`EGG_AGENT_CLOSE_TIMEOUT`: agent worker boot timeout value

## License

[MIT](LICENSE)

## Contributors

[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-cluster)](https://github.com/eggjs/egg-cluster/graphs/contributors)
[![Contributors](https://contrib.rocks/image?repo=eggjs/cluster)](https://github.com/eggjs/cluster/graphs/contributors)

Made with [contributors-img](https://contrib.rocks).
21 changes: 0 additions & 21 deletions index.js

This file was deleted.

62 changes: 0 additions & 62 deletions lib/agent_worker.js

This file was deleted.

Loading
Loading