feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
201
api.hyungi.net/node_modules/@pm2/io/LICENSE.md
generated
vendored
Normal file
201
api.hyungi.net/node_modules/@pm2/io/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2019 Keymetrics Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
73
api.hyungi.net/node_modules/@pm2/io/NOTES.md
generated
vendored
Normal file
73
api.hyungi.net/node_modules/@pm2/io/NOTES.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
|
||||
## API idea
|
||||
|
||||
require('pm2-bundle-monitoring')
|
||||
|
||||
// or
|
||||
|
||||
require('pm2-io').connect({
|
||||
secret: '',
|
||||
public: ''
|
||||
})
|
||||
|
||||
require('pm2-exception-catching')
|
||||
require('pm2-transaction-tracing').config({
|
||||
ignore_route: '/ws'
|
||||
})
|
||||
|
||||
require('pm2-frontend-monitoring')
|
||||
var pm2_metrics = require('pm2-metrics')
|
||||
|
||||
pm2_metrics.variable('BLE pairing mode', permit_join)
|
||||
pm2_metrics.variable('In memory users', () => Object.keys(users).length)
|
||||
|
||||
NOTES:
|
||||
- watch parameters is not reset on pm2 restart. only after pm2 delete
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
pm2-io-apm features are in src/features/:
|
||||
|
||||
```
|
||||
src/features/
|
||||
├── dependencies.ts
|
||||
├── entrypoint.ts
|
||||
├── events.ts
|
||||
├── metrics.ts
|
||||
├── notify.ts
|
||||
├── profiling.ts
|
||||
└── tracing.ts
|
||||
```
|
||||
|
||||
## Tracing
|
||||
|
||||
- `./src/census` folder is essentially a dump of https://github.com/census-instrumentation/opencensus-node/tree/master/packages/opencensus-nodejs-base/src/trace with plugins added
|
||||
- Only traces higher than `MINIMUM_TRACE_DURATION: 1000 * 1000` are sent to transporter (sent in /src/census/exporter.ts:72)
|
||||
|
||||
Trace sent looks like:
|
||||
|
||||
```
|
||||
{
|
||||
traceId: 'fac7052e9129416185a26d4935229620',
|
||||
name: '/slow',
|
||||
id: '66358f0a48be82c5',
|
||||
parentId: '',
|
||||
kind: 'SERVER',
|
||||
timestamp: 1586380086251000,
|
||||
duration: 2007559,
|
||||
debug: false,
|
||||
shared: false,
|
||||
localEndpoint: { serviceName: 'tototransaction' },
|
||||
tags: {
|
||||
'http.host': 'localhost',
|
||||
'http.method': 'GET',
|
||||
'http.path': '/slow',
|
||||
'http.route': '/slow',
|
||||
'http.user_agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36',
|
||||
'http.status_code': '304',
|
||||
'result.code': undefined
|
||||
}
|
||||
}
|
||||
```
|
||||
574
api.hyungi.net/node_modules/@pm2/io/README.md
generated
vendored
Normal file
574
api.hyungi.net/node_modules/@pm2/io/README.md
generated
vendored
Normal file
@@ -0,0 +1,574 @@
|
||||
<div align="center">
|
||||
<a href="http://pm2.keymetrics.io">
|
||||
<img width=411px src="https://raw.githubusercontent.com/keymetrics/pm2-io-apm/master/pres/io-white.png">
|
||||
</a>
|
||||
<br/>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
|
||||
The [@pm2/io](https://github.com/keymetrics/pm2-io-apm/tree/master/test) module comes along with PM2. It is the PM2 library responsible for gathering the metrics, reporting exceptions, exposing remote actions and every interaction with your application.
|
||||
|
||||
You can also use it as a standalone agent, if you want to connect your nodejs process to PM2 Enterprise but without having to launch your application with PM2.
|
||||
|
||||
# Table of Contents
|
||||
|
||||
- [**Installation**](https://github.com/keymetrics/pm2-io-apm/tree/master#installation)
|
||||
- [**Expose Custom Metrics**](https://github.com/keymetrics/pm2-io-apm/tree/master#expose-custom-metrics)
|
||||
- [**Expose Remote Actions**](https://github.com/keymetrics/pm2-io-apm#expose-remote-actions-trigger-functions-remotely)
|
||||
- [**Report Custom Errors**](https://github.com/keymetrics/pm2-io-apm#report-user-error)
|
||||
- [**Distributed Tracing**](https://github.com/keymetrics/pm2-io-apm#distributed-tracing)
|
||||
- [**Configuration**](https://github.com/keymetrics/pm2-io-apm/tree/master#configuration)
|
||||
- [**Migration Guide**](https://github.com/keymetrics/pm2-io-apm#migration-guides)
|
||||
- [**Development**](https://github.com/keymetrics/pm2-io-apm/tree/master#development)
|
||||
- [**Notes**](https://github.com/keymetrics/pm2-io-apm/tree/master#notes)
|
||||
|
||||
|
||||
# Installation
|
||||
|
||||
With npm:
|
||||
|
||||
```bash
|
||||
npm install @pm2/io --save
|
||||
```
|
||||
|
||||
With yarn:
|
||||
|
||||
```bash
|
||||
yarn add @pm2/io
|
||||
```
|
||||
|
||||
## V8 Runtime Metrics
|
||||
|
||||
To retrieve by default V8 Runtime metrics like:
|
||||
- V8 Garbage Collector metrics
|
||||
- [CPU Context Switch](https://unix.stackexchange.com/questions/442969/what-exactly-are-voluntary-context-switches)
|
||||
- [Page Fault](https://en.wikipedia.org/wiki/Page_fault#Types)
|
||||
|
||||
Install:
|
||||
|
||||
```bash
|
||||
npm install @pm2/node-runtime-stats
|
||||
```
|
||||
|
||||
And restart the application.
|
||||
|
||||
## Custom Metrics
|
||||
|
||||
@pm2/io allows you to gather metrics from your code to be reported in the PM2 Plus/Enterprise dashboard.
|
||||
|
||||
### Create a custom metrics
|
||||
|
||||
You can create a new custom metrics with the method `metric()` of `@pm2/io`.
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io');
|
||||
|
||||
const users = io.metric({
|
||||
name: 'Realtime user',
|
||||
});
|
||||
users.set(10)
|
||||
```
|
||||
|
||||
This arguments are available:
|
||||
|
||||
- **name**: The metric name (required; string)
|
||||
- **id**: The type of metric (default 'metric', string)
|
||||
- **unit**: unit of the measure (default ''; string)
|
||||
- **historic**: keep the history in PM2 Plus (default: true; boolean)
|
||||
|
||||
There are 4 different types of metrics:
|
||||
|
||||
- **gauge**: To expose a variable's value
|
||||
- **counter**: A discrete counter to be triggered manually to count a number of occurrence
|
||||
- **meter**: To measure a frequency, a number of occurrences of a repeating event per unit of time
|
||||
- **histogram**: To measure a statistic, a statistic on a metric over the last 5 minutes
|
||||
|
||||
### Metric: Variable Exposition
|
||||
|
||||
The first type of metric, called `metric`, allows to expose a variable's value. The variable can be exposed passively, with a function that gets called every second, or actively, with a method that you use to update the value.
|
||||
|
||||
#### Active Mode
|
||||
|
||||
In active mode, you need to create a probe and call the method `set()` to update the value.
|
||||
|
||||
```javascript
|
||||
const myMetric = io.metric({
|
||||
name: 'Realtime Value'
|
||||
});
|
||||
|
||||
myMetric.set(23);
|
||||
```
|
||||
|
||||
#### Passive Mode
|
||||
|
||||
In passive mode you hust need to return the variable to be monitored:
|
||||
|
||||
```javascript
|
||||
const myMetric = io.metric({
|
||||
name: 'Realtime Value',
|
||||
value: () => {
|
||||
return variable_to_monitor
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Counter: Discrete Counter
|
||||
|
||||
The second type of metric, called `counter`, is a discrete counter that helps you count the number of occurrence of a particular event. The counter starts at 0 and can be incremented or decremented.
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io');
|
||||
|
||||
const currentReq = io.counter({
|
||||
name: 'Current req processed',
|
||||
type: 'counter',
|
||||
});
|
||||
|
||||
http.createServer((req, res) => {
|
||||
// Increment the counter, counter will eq 1
|
||||
currentReq.inc();
|
||||
req.on('end', () => {
|
||||
// Decrement the counter, counter will eq 0
|
||||
currentReq.dec();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### Meter: Frequency
|
||||
|
||||
The third type of metric, called `meter`, compute the frequency of an event. Each time the event happens, you need to call the `mark()` method. By default, the frequency is the number of events per second over the last minute.
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io');
|
||||
|
||||
const reqsec = io.meter({
|
||||
name: 'req/sec',
|
||||
type: 'meter',
|
||||
});
|
||||
|
||||
http.createServer((req, res) => {
|
||||
reqsec.mark();
|
||||
res.end({ success: true });
|
||||
});
|
||||
```
|
||||
|
||||
Additional options:
|
||||
- **samples**: (optional)(default: 1) Rate unit. Defaults to **1** sec.
|
||||
- **timeframe**: (optional)(default: 60) Timeframe over which the events will be analyzed. Defaults to **60** sec.
|
||||
|
||||
### Histogram: Statistics
|
||||
|
||||
Collect values and provide statistic tools to explore their distribution over the last 5 minutes.
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io');
|
||||
|
||||
const latency = io.histogram({
|
||||
name: 'latency',
|
||||
measurement: 'mean'
|
||||
});
|
||||
|
||||
var latencyValue = 0;
|
||||
|
||||
setInterval(() => {
|
||||
latencyValue = Math.round(Math.random() * 100);
|
||||
latency.update(latencyValue);
|
||||
}, 100);
|
||||
```
|
||||
|
||||
Options are:
|
||||
- **measurement** : default: mean; min, max, sum, count, variance, mean, stddev, median, p75, p95, p99, p99.
|
||||
|
||||
## Expose Remote Actions: Trigger Functions remotely
|
||||
|
||||
Remotely trigger functions from PM2 Plus or Enterprise.
|
||||
|
||||
### Simple actions
|
||||
|
||||
The function takes a function as a parameter (cb here) and need to be called once the job is finished.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io');
|
||||
|
||||
io.action('db:clean', (cb) => {
|
||||
clean.db(() => {
|
||||
// cb must be called at the end of the action
|
||||
return cb({ success: true });
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## Report user error
|
||||
|
||||
By default, in the Issue tab, you are only alerted for uncaught exceptions. Any exception that you catch is not reported. You can manually report them with the `notifyError()` method.
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io');
|
||||
|
||||
io.notifyError(new Error('This is an error'), {
|
||||
// you can some http context that will be reported in the UI
|
||||
http: {
|
||||
url: req.url
|
||||
},
|
||||
// or anything that you can like an user id
|
||||
custom: {
|
||||
user: req.user.id
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
#### Express error reporting
|
||||
|
||||
If you want you can configure your express middleware to automatically send you an error with the error middleware of express :
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io')
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
|
||||
// add the routes that you want
|
||||
app.use('/toto', () => {
|
||||
throw new Error('ajdoijerr')
|
||||
})
|
||||
|
||||
// always add the middleware as the last one
|
||||
app.use(io.expressErrorHandler())
|
||||
```
|
||||
|
||||
#### Koa error reporting
|
||||
|
||||
We also expose a custom koa middleware to report error with a specific koa middleware :
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io')
|
||||
const Koa = require('koa')
|
||||
const app = new Koa()
|
||||
|
||||
// the order isn't important with koa
|
||||
app.use(pmx.koaErrorHandler())
|
||||
|
||||
// add the routes that you want
|
||||
app.use(async ctx => {
|
||||
ctx.throw(new Error('toto'))
|
||||
})
|
||||
```
|
||||
|
||||
## Distributed Tracing
|
||||
|
||||
The Distributed Tracing allows to captures and propagates distributed traces through your system, allowing you to visualize how customer requests flow across services, rapidly perform deep root cause analysis, and better analyze latency across a highly distributed set of services.
|
||||
If you want to enable it, here the simple options to enable:
|
||||
|
||||
|
||||
```javascript
|
||||
const io = require('@pm2/io').init({
|
||||
tracing: {
|
||||
enabled: true,
|
||||
// will add the actual queries made to database, false by default
|
||||
detailedDatabasesCalls: true,
|
||||
// if you want you can ignore some endpoint based on their path
|
||||
ignoreIncomingPaths: [
|
||||
// can be a regex
|
||||
/misc/,
|
||||
// or a exact string
|
||||
'/api/bucket'
|
||||
// or a function with the request
|
||||
(url, request) => {
|
||||
return true
|
||||
}
|
||||
],
|
||||
// same as above but used to match entire URLs
|
||||
ignoreOutgoingUrls: [],
|
||||
/**
|
||||
* Determines the probability of a request to be traced. Ranges from 0.0 to 1.0
|
||||
* default is 0.5
|
||||
*/
|
||||
samplingRate: 0.5
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
By default we ignore specific incoming requests (you can override this by setting `ignoreIncomingPaths: []`):
|
||||
- Request with the OPTIONS or HEAD method
|
||||
- Request fetching a static ressources (`*.js`, `*.css`, `*.ico`, `*.svg`, `.png` or `*webpack*`)
|
||||
|
||||
### What's get traced
|
||||
|
||||
When your application will receive a request from either `http`, `https` or `http2` it will start a trace. After that, we will trace the following modules:
|
||||
- `http` outgoing requests
|
||||
- `https` outgoing requests
|
||||
- `http2` outgoing requests
|
||||
- `mongodb-core` version 1 - 3
|
||||
- `redis` versions > 2.6
|
||||
- `ioredis` versions > 2.6
|
||||
- `mysql` version 1 - 3
|
||||
- `mysql2` version 1 - 3
|
||||
- `pg` version > 6
|
||||
- `vue-server-renderer` version 2
|
||||
|
||||
### Custom Tracing API
|
||||
|
||||
The custom tracing API can be used to create custom trace spans. A span is a particular unit of work within a trace, such as an RPC request. Spans may be nested; the outermost span is called a root span, even if there are no nested child spans. Root spans typically correspond to incoming requests, while child spans typically correspond to outgoing requests, or other work that is triggered in response to incoming requests. This means that root spans shouldn't be created in a context where a root span already exists; a child span is more suitable here. Instead, root spans should be created to track work that happens outside of the request lifecycle entirely, such as periodically scheduled work. To illustrate:
|
||||
|
||||
```js
|
||||
const io = require('@pm2/io').init({ tracing: true })
|
||||
const tracer = io.getTracer()
|
||||
// ...
|
||||
|
||||
app.get('/:token', function (req, res) {
|
||||
const token = req.params.token
|
||||
// the '2' correspond to the type of operation you want to trace
|
||||
// can be 0 (UNKNOWN), 1 (SERVER) or 2 (CLIENT)
|
||||
// 'verifyToken' here will be the name of the operation
|
||||
const customSpan = tracer.startChildSpan('verifyToken', 2)
|
||||
// note that customSpan can be null if you are not inside a request
|
||||
req.Token.verifyToken(token, (err, result) => {
|
||||
if (err) {
|
||||
// you can add tags to the span to attach more details to the span
|
||||
customSpan.addAttribute('error', err.message)
|
||||
customSpan.end()
|
||||
return res.status(500).send('error')
|
||||
}
|
||||
customSpan.addAttribute('result', result)
|
||||
// be sure to always .end() the spans
|
||||
customSpan.end()
|
||||
// redirect the user if the token is valid
|
||||
res.send('/user/me')
|
||||
})
|
||||
})
|
||||
|
||||
// For any significant work done _outside_ of the request lifecycle, use
|
||||
// startRootSpan.
|
||||
const traceOptions = {
|
||||
name: 'my custom trace',
|
||||
// the '1' correspond to the type of operation you want to trace
|
||||
// can be 0 (UNKNOWN), 1 (SERVER) or 2 (CLIENT)
|
||||
kind: '1'
|
||||
}
|
||||
plugin.tracer.startRootSpan(traceOptions, rootSpan => {
|
||||
// ...
|
||||
// Be sure to call rootSpan.end().
|
||||
rootSpan.end()
|
||||
});
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Global configuration object
|
||||
|
||||
```javascript
|
||||
export class IOConfig {
|
||||
/**
|
||||
* Automatically catch unhandled errors
|
||||
*/
|
||||
catchExceptions?: boolean = true
|
||||
/**
|
||||
* Configure the metrics to add automatically to your process
|
||||
*/
|
||||
metrics?: {
|
||||
eventLoop: boolean = true,
|
||||
network: boolean = false,
|
||||
http: boolean = true,
|
||||
gc: boolean = true,
|
||||
v8: boolean = true
|
||||
}
|
||||
/**
|
||||
* Configure the default actions that you can run
|
||||
*/
|
||||
actions?: {
|
||||
eventLoopDump?: boolean = true
|
||||
}
|
||||
/**
|
||||
* Configure availables profilers that will be exposed
|
||||
*/
|
||||
profiling?: {
|
||||
/**
|
||||
* Toggle the CPU profiling actions
|
||||
*/
|
||||
cpuJS: boolean = true
|
||||
/**
|
||||
* Toggle the heap snapshot actions
|
||||
*/
|
||||
heapSnapshot: boolean = true
|
||||
/**
|
||||
* Toggle the heap sampling actions
|
||||
*/
|
||||
heapSampling: boolean = true
|
||||
/**
|
||||
* Force a specific implementation of profiler
|
||||
*
|
||||
* available:
|
||||
* - 'addon' (using the v8-profiler-node8 addon)
|
||||
* - 'inspector' (using the "inspector" api from node core)
|
||||
* - 'none' (disable the profilers)
|
||||
* - 'both' (will try to use inspector and fallback on addon if available)
|
||||
*/
|
||||
implementation: string = 'both'
|
||||
}
|
||||
/**
|
||||
* Configure the transaction tracing options
|
||||
*/
|
||||
tracing?: {
|
||||
/**
|
||||
* Enabled the distributed tracing feature.
|
||||
*/
|
||||
enabled: boolean
|
||||
/**
|
||||
* If you want to report a specific service name
|
||||
* the default is the same as in apmOptions
|
||||
*/
|
||||
serviceName?: string
|
||||
/**
|
||||
* Generate trace for outgoing request that aren't connected to a incoming one
|
||||
* default is false
|
||||
*/
|
||||
outbound?: boolean
|
||||
/**
|
||||
* Determines the probability of a request to be traced. Ranges from 0.0 to 1.0
|
||||
* default is 0.5
|
||||
*/
|
||||
samplingRate?: number,
|
||||
/**
|
||||
* Add details about databases calls (redis, mongodb etc)
|
||||
*/
|
||||
detailedDatabasesCalls?: boolean,
|
||||
/**
|
||||
* Ignore specific incoming request depending on their path
|
||||
*/
|
||||
ignoreIncomingPaths?: Array<IgnoreMatcher<httpModule.IncomingMessage>>
|
||||
/**
|
||||
* Ignore specific outgoing request depending on their url
|
||||
*/
|
||||
ignoreOutgoingUrls?: Array<IgnoreMatcher<httpModule.ClientRequest>>
|
||||
/**
|
||||
* Set to true when wanting to create span for raw TCP connection
|
||||
* instead of new http request
|
||||
*/
|
||||
createSpanWithNet: boolean
|
||||
}
|
||||
/**
|
||||
* If you want to connect to PM2 Enterprise without using PM2, you should enable
|
||||
* the standalone mode
|
||||
*
|
||||
* default is false
|
||||
*/
|
||||
standalone?: boolean = false
|
||||
/**
|
||||
* Define custom options for the standalone mode
|
||||
*/
|
||||
apmOptions?: {
|
||||
/**
|
||||
* public key of the bucket to which the agent need to connect
|
||||
*/
|
||||
publicKey: string
|
||||
/**
|
||||
* Secret key of the bucket to which the agent need to connect
|
||||
*/
|
||||
secretKey: string
|
||||
/**
|
||||
* The name of the application/service that will be reported to PM2 Enterprise
|
||||
*/
|
||||
appName: string
|
||||
/**
|
||||
* The name of the server as reported in PM2 Enterprise
|
||||
*
|
||||
* default is os.hostname()
|
||||
*/
|
||||
serverName?: string
|
||||
/**
|
||||
* Broadcast all the logs from your application to our backend
|
||||
*/
|
||||
sendLogs?: Boolean
|
||||
/**
|
||||
* Avoid to broadcast any logs from your application to our backend
|
||||
* Even if the sendLogs option set to false, you can still see some logs
|
||||
* when going to the log interface (it automatically trigger broacasting log)
|
||||
*/
|
||||
disableLogs?: Boolean
|
||||
/**
|
||||
* Since logs can be forwared to our backend you may want to ignore specific
|
||||
* logs (containing sensitive data for example)
|
||||
*/
|
||||
logFilter?: string | RegExp
|
||||
/**
|
||||
* Proxy URI to use when reaching internet
|
||||
* Supporting socks5,http,https,pac,socks4
|
||||
* see https://github.com/TooTallNate/node-proxy-agent
|
||||
*
|
||||
* example: socks5://username:password@some-socks-proxy.com:9050
|
||||
*/
|
||||
proxy?: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can pass whatever options you want to `io.init`, it will automatically update its configuration.
|
||||
|
||||
## Migration Guides
|
||||
|
||||
### 2.x to 3.x
|
||||
|
||||
Here the list of breaking changes :
|
||||
|
||||
- Removed `io.scopedAction` because of low user adoption
|
||||
- Removed `io.notify` in favor of `io.notifyError` (droppin replacement)
|
||||
- Removed support for `gc-stats` module
|
||||
- Removed Heap profiling support when using the profiler addon (which wasn't possible at all)
|
||||
- Removed deep-metrics support (the module that allowed to get metrics about websocket/mongo out of the box), we are working on a better solution.
|
||||
- Removed `io.transpose`
|
||||
- Removed `io.probe()` to init metrics
|
||||
- **Changed the configuration structure**
|
||||
|
||||
High chance that if you used a custom configuration for `io.init`, you need to change it to reflect the new configuration.
|
||||
Apart from that and the `io.notify` removal, it shouldn't break the way you instanciated metrics.
|
||||
If you find something else that breaks please report it to us (tech@keymetrics.io).
|
||||
|
||||
### 3.x to 4.x
|
||||
|
||||
The only difference with the 4.x version is the new tracing system put in place, so the only changs are related to it:
|
||||
|
||||
- **Dropped the support for node 4** (you can still use the 3.x if you use node 4 but you will not have access to the distributed tracing)
|
||||
- **Changed the tracing configuration** (see options above)
|
||||
|
||||
## Development
|
||||
|
||||
To auto rebuild on file change:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm run watch
|
||||
```
|
||||
|
||||
To test only one file:
|
||||
|
||||
```bash
|
||||
$ npm run unit <typescript-file-to-test.ts>
|
||||
```
|
||||
|
||||
Run transpilation + test + coverage:
|
||||
|
||||
```bash
|
||||
$ npm run test
|
||||
```
|
||||
|
||||
Run transpilation + test only:
|
||||
|
||||
```bash
|
||||
$ npm run unit <test>
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
Curently this package isn't compatible with `amqp` if you use the `network` metrics. We recommend to disable the metrics with the following configuration in this case :
|
||||
|
||||
```javascript
|
||||
io.init({
|
||||
metrics: {
|
||||
network: false
|
||||
}
|
||||
})
|
||||
```
|
||||
6
api.hyungi.net/node_modules/@pm2/io/build/main/configuration.d.ts
generated
vendored
Normal file
6
api.hyungi.net/node_modules/@pm2/io/build/main/configuration.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export default class Configuration {
|
||||
static configureModule(opts: any): void;
|
||||
static findPackageJson(): string | null | undefined;
|
||||
static init(conf: any, doNotTellPm2?: any): any;
|
||||
static getMain(): any;
|
||||
}
|
||||
124
api.hyungi.net/node_modules/@pm2/io/build/main/configuration.js
generated
vendored
Normal file
124
api.hyungi.net/node_modules/@pm2/io/build/main/configuration.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
api.hyungi.net/node_modules/@pm2/io/build/main/constants.d.ts
generated
vendored
Normal file
5
api.hyungi.net/node_modules/@pm2/io/build/main/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
declare const _default: {
|
||||
METRIC_INTERVAL: number;
|
||||
};
|
||||
export default _default;
|
||||
export declare function canUseInspector(): any;
|
||||
16
api.hyungi.net/node_modules/@pm2/io/build/main/constants.js
generated
vendored
Normal file
16
api.hyungi.net/node_modules/@pm2/io/build/main/constants.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.canUseInspector = void 0;
|
||||
const semver = require("semver");
|
||||
exports.default = {
|
||||
METRIC_INTERVAL: 990
|
||||
};
|
||||
function canUseInspector() {
|
||||
const isAboveNode10 = semver.satisfies(process.version, '>= 10.1.0');
|
||||
const isAboveNode8 = semver.satisfies(process.version, '>= 8.0.0');
|
||||
const canUseInNode8 = process.env.FORCE_INSPECTOR === '1'
|
||||
|| process.env.FORCE_INSPECTOR === 'true' || process.env.NODE_ENV === 'production';
|
||||
return isAboveNode10 || (isAboveNode8 && canUseInNode8);
|
||||
}
|
||||
exports.canUseInspector = canUseInspector;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxpQ0FBZ0M7QUFFaEMsa0JBQWU7SUFDYixlQUFlLEVBQUUsR0FBRztDQUNyQixDQUFBO0FBRUQsU0FBZ0IsZUFBZTtJQUM3QixNQUFNLGFBQWEsR0FBRyxNQUFNLENBQUMsU0FBUyxDQUFDLE9BQU8sQ0FBQyxPQUFPLEVBQUUsV0FBVyxDQUFDLENBQUE7SUFDcEUsTUFBTSxZQUFZLEdBQUcsTUFBTSxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBO0lBQ2xFLE1BQU0sYUFBYSxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsZUFBZSxLQUFLLEdBQUc7V0FDcEQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLEtBQUssTUFBTSxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxLQUFLLFlBQVksQ0FBQTtJQUNwRixPQUFPLGFBQWEsSUFBSSxDQUFDLFlBQVksSUFBSSxhQUFhLENBQUMsQ0FBQTtBQUN6RCxDQUFDO0FBTkQsMENBTUMifQ==
|
||||
14
api.hyungi.net/node_modules/@pm2/io/build/main/featureManager.d.ts
generated
vendored
Normal file
14
api.hyungi.net/node_modules/@pm2/io/build/main/featureManager.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { IOConfig } from './pmx';
|
||||
export declare function getObjectAtPath(context: Object, path: string): any;
|
||||
export declare class FeatureManager {
|
||||
private logger;
|
||||
init(options: IOConfig): void;
|
||||
get(name: string): Feature;
|
||||
destroy(): void;
|
||||
}
|
||||
export declare class FeatureConfig {
|
||||
}
|
||||
export interface Feature {
|
||||
init(config?: any): void;
|
||||
destroy(): void;
|
||||
}
|
||||
100
api.hyungi.net/node_modules/@pm2/io/build/main/featureManager.js
generated
vendored
Normal file
100
api.hyungi.net/node_modules/@pm2/io/build/main/featureManager.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FeatureConfig = exports.FeatureManager = exports.getObjectAtPath = void 0;
|
||||
const notify_1 = require("./features/notify");
|
||||
const profiling_1 = require("./features/profiling");
|
||||
const events_1 = require("./features/events");
|
||||
const metrics_1 = require("./features/metrics");
|
||||
const dependencies_1 = require("./features/dependencies");
|
||||
const Debug = require("debug");
|
||||
function getObjectAtPath(context, path) {
|
||||
if (path.indexOf('.') === -1 && path.indexOf('[') === -1) {
|
||||
return context[path];
|
||||
}
|
||||
let crumbs = path.split(/\.|\[|\]/g);
|
||||
let i = -1;
|
||||
let len = crumbs.length;
|
||||
let result;
|
||||
while (++i < len) {
|
||||
if (i === 0)
|
||||
result = context;
|
||||
if (!crumbs[i])
|
||||
continue;
|
||||
if (result === undefined)
|
||||
break;
|
||||
result = result[crumbs[i]];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.getObjectAtPath = getObjectAtPath;
|
||||
class AvailableFeature {
|
||||
}
|
||||
const availablesFeatures = [
|
||||
{
|
||||
name: 'notify',
|
||||
optionsPath: '.',
|
||||
module: notify_1.NotifyFeature
|
||||
},
|
||||
{
|
||||
name: 'profiler',
|
||||
optionsPath: 'profiling',
|
||||
module: profiling_1.ProfilingFeature
|
||||
},
|
||||
{
|
||||
name: 'events',
|
||||
module: events_1.EventsFeature
|
||||
},
|
||||
{
|
||||
name: 'metrics',
|
||||
optionsPath: 'metrics',
|
||||
module: metrics_1.MetricsFeature
|
||||
},
|
||||
{
|
||||
name: 'dependencies',
|
||||
module: dependencies_1.DependenciesFeature
|
||||
}
|
||||
];
|
||||
class FeatureManager {
|
||||
constructor() {
|
||||
this.logger = Debug('axm:features');
|
||||
}
|
||||
init(options) {
|
||||
for (let availableFeature of availablesFeatures) {
|
||||
this.logger(`Creating feature ${availableFeature.name}`);
|
||||
const feature = new availableFeature.module();
|
||||
let config = undefined;
|
||||
if (typeof availableFeature.optionsPath !== 'string') {
|
||||
config = {};
|
||||
}
|
||||
else if (availableFeature.optionsPath === '.') {
|
||||
config = options;
|
||||
}
|
||||
else {
|
||||
config = getObjectAtPath(options, availableFeature.optionsPath);
|
||||
}
|
||||
this.logger(`Init feature ${availableFeature.name}`);
|
||||
feature.init(config);
|
||||
availableFeature.instance = feature;
|
||||
}
|
||||
}
|
||||
get(name) {
|
||||
const feature = availablesFeatures.find(feature => feature.name === name);
|
||||
if (feature === undefined || feature.instance === undefined) {
|
||||
throw new Error(`Tried to call feature ${name} which doesn't exist or wasn't initiated`);
|
||||
}
|
||||
return feature.instance;
|
||||
}
|
||||
destroy() {
|
||||
for (let availableFeature of availablesFeatures) {
|
||||
if (availableFeature.instance === undefined)
|
||||
continue;
|
||||
this.logger(`Destroy feature ${availableFeature.name}`);
|
||||
availableFeature.instance.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.FeatureManager = FeatureManager;
|
||||
class FeatureConfig {
|
||||
}
|
||||
exports.FeatureConf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FFLFNBQVE7WUFDckQsSUFBSSxDQUFDLE1BQU0sQ0FBQyxtQkFBbUIsZ0JBQWdCLENBQUMsSUFBSSxFQUFFLENBQUMsQ0FBQTtZQUN2RCxnQkFBZ0IsQ0FBQyxRQUFRLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDckMsQ0FBQztJQUNILENBQUM7Q0FDRjtBQS9DRCx3Q0ErQ0M7QUFHRCxNQUFhLGFBQWE7Q0FBSTtBQUE5QixzQ0FBOEIifQ==
|
||||
7
api.hyungi.net/node_modules/@pm2/io/build/main/features/dependencies.d.ts
generated
vendored
Normal file
7
api.hyungi.net/node_modules/@pm2/io/build/main/features/dependencies.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Feature } from '../featureManager';
|
||||
export declare class DependenciesFeature implements Feature {
|
||||
private transport;
|
||||
private logger;
|
||||
init(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
46
api.hyungi.net/node_modules/@pm2/io/build/main/features/dependencies.js
generated
vendored
Normal file
46
api.hyungi.net/node_modules/@pm2/io/build/main/features/dependencies.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DependenciesFeature = void 0;
|
||||
const serviceManager_1 = require("../serviceManager");
|
||||
const Debug = require("debug");
|
||||
const configuration_1 = require("../configuration");
|
||||
const fs_1 = require("fs");
|
||||
class DependenciesFeature {
|
||||
constructor() {
|
||||
this.logger = Debug('axm:features:dependencies');
|
||||
}
|
||||
init() {
|
||||
this.transport = serviceManager_1.ServiceManager.get('transport');
|
||||
this.logger('init');
|
||||
const pkgPath = configuration_1.default.findPackageJson();
|
||||
if (typeof pkgPath !== 'string')
|
||||
return this.logger('failed to found pkg.json path');
|
||||
this.logger(`found pkg.json in ${pkgPath}`);
|
||||
(0, fs_1.readFile)(pkgPath, (err, data) => {
|
||||
if (err)
|
||||
return this.logger(`failed to read pkg.json`, err);
|
||||
try {
|
||||
const pkg = JSON.parse(data.toString());
|
||||
if (typeof pkg.dependencies !== 'object') {
|
||||
return this.logger(`failed to find deps in pkg.json`);
|
||||
}
|
||||
const dependencies = Object.keys(pkg.dependencies)
|
||||
.reduce((list, name) => {
|
||||
list[name] = { version: pkg.dependencies[name] };
|
||||
return list;
|
||||
}, {});
|
||||
this.logger(`collected ${Object.keys(dependencies).length} dependencies`);
|
||||
this.transport.send('application:dependencies', dependencies);
|
||||
this.logger('sent dependencies list');
|
||||
}
|
||||
catch (err) {
|
||||
return this.logger(`failed to parse pkg.json`, err);
|
||||
}
|
||||
});
|
||||
}
|
||||
destroy() {
|
||||
this.logger('destroy');
|
||||
}
|
||||
}
|
||||
exports.DependenciesFeature = DependenciesFeature;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwZW5kZW5jaWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2ZlYXR1cmVzL2RlcGVuZGVuY2llcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxzREFBa0Q7QUFDbEQsK0JBQThCO0FBRzlCLG9EQUE0QztBQUM1QywyQkFBNkI7QUFLN0IsTUFBYSxtQkFBbUI7SUFBaEM7UUFHVSxXQUFNLEdBQWEsS0FBSyxDQUFDLDJCQUEyQixDQUFDLENBQUE7SUFrQy9ELENBQUM7SUFoQ0MsSUFBSTtRQUNGLElBQUksQ0FBQyxTQUFTLEdBQUcsK0JBQWMsQ0FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLENBQUE7UUFDaEQsSUFBSSxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsQ0FBQTtRQUVuQixNQUFNLE9BQU8sR0FBRyx1QkFBYSxDQUFDLGVBQWUsRUFBRSxDQUFBO1FBQy9DLElBQUksT0FBTyxPQUFPLEtBQUssUUFBUTtZQUFFLE9BQU8sSUFBSSxDQUFDLE1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sRUFBRSxZQUFZLENBQUMsQ0FBQTtnQkFDN0QsSUFBSSxDQUFDLE1BQU0sQ0FBQyx3QkFBd0IsQ0FBQyxDQUFBO1lBQ3ZDLENBQUM7WUFBQyxPQUFPLEdBQUcsRUFBRSxDQUFDO2dCQUNiLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQywwQkFBMEIsRUFBRSxHQUFHLENBQUMsQ0FBQTtZQUNyRCxDQUFDO1FBQ0gsQ0FBQyxDQUFDLENBQUE7SUFDSixDQUFDO0lBRUQsT0FBTztRQUNMLElBQUksQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLENBQUE7SUFDeEIsQ0FBQztDQUNGO0FBckNELGtEQXFDQyJ9
|
||||
11
api.hyungi.net/node_modules/@pm2/io/build/main/features/entrypoint.d.ts
generated
vendored
Normal file
11
api.hyungi.net/node_modules/@pm2/io/build/main/features/entrypoint.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { IOConfig } from '../pmx';
|
||||
export declare class Entrypoint {
|
||||
private io;
|
||||
constructor();
|
||||
events(): void;
|
||||
sensors(): void;
|
||||
actuators(): void;
|
||||
onStart(cb: Function): void;
|
||||
onStop(err: Error, cb: Function, code: number, signal: string): any;
|
||||
conf(): IOConfig | undefined;
|
||||
}
|
||||
53
api.hyungi.net/node_modules/@pm2/io/build/main/features/entrypoint.js
generated
vendored
Normal file
53
api.hyungi.net/node_modules/@pm2/io/build/main/features/entrypoint.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Entrypoint = void 0;
|
||||
const IO_KEY = Symbol.for('@pm2/io');
|
||||
class Entrypoint {
|
||||
constructor() {
|
||||
try {
|
||||
this.io = global[IO_KEY].init(this.conf());
|
||||
this.onStart(err => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
this.sensors();
|
||||
this.events();
|
||||
this.actuators();
|
||||
this.io.onExit((code, signal) => {
|
||||
this.onStop(err, () => {
|
||||
this.io.destroy();
|
||||
}, code, signal);
|
||||
});
|
||||
if (process && process.send)
|
||||
process.send('ready');
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (this.io) {
|
||||
this.io.destroy();
|
||||
}
|
||||
throw (e);
|
||||
}
|
||||
}
|
||||
events() {
|
||||
return;
|
||||
}
|
||||
sensors() {
|
||||
return;
|
||||
}
|
||||
actuators() {
|
||||
return;
|
||||
}
|
||||
onStart(cb) {
|
||||
throw new Error('Entrypoint onStart() not specified');
|
||||
}
|
||||
onStop(err, cb, code, signal) {
|
||||
return cb();
|
||||
}
|
||||
conf() {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.Entrypoint = Entrypoint;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW50cnlwb2ludC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9mZWF0dXJlcy9lbnRyeXBvaW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBLE1BQU0sTUFBTSxHQUFHLE1BQU0sQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLENBQUE7QUFFcEMsTUFBYSxVQUFVO0lBR3JCO1FBQ0UsSUFBSSxDQUFDO1lBQ0gsSUFBSSxDQUFDLEVBQUUsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFBO1lBRTFDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUU7Z0JBQ2pCLElBQUksR0FBRyxFQUFFLENBQUM7b0JBQ1IsT0FBTyxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQTtvQkFDbEIsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENB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0FBRSxHQUFVLEVBQUUsRUFBWSxFQUFFLElBQVksRUFBRSxNQUFjO1FBQzVELE9BQU8sRUFBRSxFQUFFLENBQUE7SUFDYixDQUFDO0lBRUQsSUFBSTtRQUNGLE9BQU8sU0FBUyxDQUFBO0lBQ2xCLENBQUM7Q0FDRjtBQTFERCxnQ0EwREMifQ==
|
||||
8
api.hyungi.net/node_modules/@pm2/io/build/main/features/events.d.ts
generated
vendored
Normal file
8
api.hyungi.net/node_modules/@pm2/io/build/main/features/events.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Feature } from '../featureManager';
|
||||
export declare class EventsFeature implements Feature {
|
||||
private transport;
|
||||
private logger;
|
||||
init(): void;
|
||||
emit(name?: string, data?: any): any;
|
||||
destroy(): void;
|
||||
}
|
||||
45
api.hyungi.net/node_modules/@pm2/io/build/main/features/events.js
generated
vendored
Normal file
45
api.hyungi.net/node_modules/@pm2/io/build/main/features/events.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EventsFeature = void 0;
|
||||
const serviceManager_1 = require("../serviceManager");
|
||||
const Debug = require("debug");
|
||||
class EventsFeature {
|
||||
constructor() {
|
||||
this.logger = Debug('axm:features:events');
|
||||
}
|
||||
init() {
|
||||
this.transport = serviceManager_1.ServiceManager.get('transport');
|
||||
this.logger('init');
|
||||
}
|
||||
emit(name, data) {
|
||||
if (typeof name !== 'string') {
|
||||
console.error('event name must be a string');
|
||||
return console.trace();
|
||||
}
|
||||
if (typeof data !== 'object') {
|
||||
console.error('event data must be an object');
|
||||
return console.trace();
|
||||
}
|
||||
if (data instanceof Array) {
|
||||
console.error(`event data cannot be an array`);
|
||||
return console.trace();
|
||||
}
|
||||
let inflightObj = {};
|
||||
try {
|
||||
inflightObj = JSON.parse(JSON.stringify(data));
|
||||
}
|
||||
catch (err) {
|
||||
return console.log('Failed to serialize the event data', err.message);
|
||||
}
|
||||
inflightObj.__name = name;
|
||||
if (this.transport === undefined) {
|
||||
return this.logger('Failed to send event as transporter isnt available');
|
||||
}
|
||||
this.transport.send('human:event', inflightObj);
|
||||
}
|
||||
destroy() {
|
||||
this.logger('destroy');
|
||||
}
|
||||
}
|
||||
exports.EventsFeature = EventsFeature;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2ZlYXR1cmVzL2V2ZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxzREFBa0Q7QUFHbEQsK0JBQThCO0FBRTlCLE1BQWEsYUFBYTtJQUExQjtRQUdVLFdBQU0sR0FBYSxLQUFLLENBQUMscUJBQXFCLENBQUMsQ0FBQTtJQXNDekQsQ0FBQztJQXBDQyxJQUFJO1FBQ0YsSUFBSSxDQUFDLFNBQVMsR0FBRywrQkFBYyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUNoRCxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3JCLENBQUM7SUFFRCxJQUFJLENBQUUsSUFBYSxFQUFFLElBQVU7UUFDN0IsSUFBSSxPQUFPLElBQUksS0FBSyxRQUFRLEVBQUUsQ0FBQztZQUM3QixPQUFPLENBQUMsS0FBSyxDQUFDLDZCQUE2QixDQUFDLENBQUE7WUFDNUMsT0FBTyxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDeEIsQ0FBQztRQUNELElBQUksT0FBTyxJQUFJLEtBQUssUUFBUSxFQUFFLENBQUM7WUFDN0IsT0FBTyxDQUFDLEtBQUssQ0FBQyw4QkFBOEIsQ0FBQyxDQUFBO1lBQzdDLE9BQU8sT0FBTyxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ3hCLENBQUM7UUFDRCxJQUFJLElBQUksWUFBWSxLQUFLLEVBQUUsQ0FBQztZQUMxQixPQUFPLENBQUMsS0FBSyxDQUFDLCtCQUErQixDQUFDLENBQUE7WUFDOUMsT0FBTyxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDeEIsQ0FBQztRQUVELElBQUksV0FBVyxHQUFpQixFQUFFLENBQUE7UUFDbEMsSUFBSSxDQUFDO1lBQ0gsV0FBVyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFBO1FBQ2hELENBQUM7UUFBQyxPQUFPLEdBQUcsRUFBRSxDQUFDO1lBQ2IsT0FBTyxPQUFPLENBQUMsR0FBRyxDQUFDLG9DQUFvQyxFQUFFLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQTtRQUN2RSxDQUFDO1FBRUQsV0FBVyxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUE7UUFDekIsSUFBSSxJQUFJLENBQUMsU0FBUyxLQUFLLFNBQVMsRUFBRSxDQUFDO1lBQ2pDLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxvREFBb0QsQ0FBQyxDQUFBO1FBQzFFLENBQUM7UUFDRCxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxhQUFhLEVBQUUsV0FBVyxDQUFDLENBQUE7SUFDakQsQ0FBQztJQUVELE9BQU87UUFDTCxJQUFJLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3hCLENBQUM7Q0FDRjtBQXpDRCxzQ0F5Q0MifQ==
|
||||
24
api.hyungi.net/node_modules/@pm2/io/build/main/features/metrics.d.ts
generated
vendored
Normal file
24
api.hyungi.net/node_modules/@pm2/io/build/main/features/metrics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Feature } from '../featureManager';
|
||||
import { EventLoopMetricOption } from '../metrics/eventLoopMetrics';
|
||||
import { NetworkTrafficConfig } from '../metrics/network';
|
||||
import { HttpMetricsConfig } from '../metrics/httpMetrics';
|
||||
import { V8MetricsConfig } from '../metrics/v8';
|
||||
import { RuntimeMetricsOptions } from '../metrics/runtime';
|
||||
export declare const defaultMetricConf: MetricConfig;
|
||||
export declare class MetricConfig {
|
||||
v8?: V8MetricsConfig | boolean;
|
||||
runtime?: RuntimeMetricsOptions | boolean;
|
||||
http?: HttpMetricsConfig | boolean;
|
||||
network?: NetworkTrafficConfig | boolean;
|
||||
eventLoop?: EventLoopMetricOption | boolean;
|
||||
}
|
||||
export interface MetricInterface {
|
||||
init(config?: Object | boolean): void;
|
||||
destroy(): void;
|
||||
}
|
||||
export declare class MetricsFeature implements Feature {
|
||||
private logger;
|
||||
init(options?: Object): void;
|
||||
get(name: string): MetricInterface | undefined;
|
||||
destroy(): void;
|
||||
}
|
||||
90
api.hyungi.net/node_modules/@pm2/io/build/main/features/metrics.js
generated
vendored
Normal file
90
api.hyungi.net/node_modules/@pm2/io/build/main/features/metrics.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MetricsFeature = exports.MetricConfig = exports.defaultMetricConf = void 0;
|
||||
const debug_1 = require("debug");
|
||||
const featureManager_1 = require("../featureManager");
|
||||
const eventLoopMetrics_1 = require("../metrics/eventLoopMetrics");
|
||||
const network_1 = require("../metrics/network");
|
||||
const httpMetrics_1 = require("../metrics/httpMetrics");
|
||||
const v8_1 = require("../metrics/v8");
|
||||
const runtime_1 = require("../metrics/runtime");
|
||||
exports.defaultMetricConf = {
|
||||
eventLoop: true,
|
||||
network: false,
|
||||
http: true,
|
||||
runtime: true,
|
||||
v8: true
|
||||
};
|
||||
class MetricConfig {
|
||||
}
|
||||
exports.MetricConfig = MetricConfig;
|
||||
class AvailableMetric {
|
||||
}
|
||||
const availableMetrics = [
|
||||
{
|
||||
name: 'eventloop',
|
||||
module: eventLoopMetrics_1.default,
|
||||
optionsPath: 'eventLoop'
|
||||
},
|
||||
{
|
||||
name: 'http',
|
||||
module: httpMetrics_1.default,
|
||||
optionsPath: 'http'
|
||||
},
|
||||
{
|
||||
name: 'network',
|
||||
module: network_1.default,
|
||||
optionsPath: 'network'
|
||||
},
|
||||
{
|
||||
name: 'v8',
|
||||
module: v8_1.default,
|
||||
optionsPath: 'v8'
|
||||
},
|
||||
{
|
||||
name: 'runtime',
|
||||
module: runtime_1.default,
|
||||
optionsPath: 'runtime'
|
||||
}
|
||||
];
|
||||
class MetricsFeature {
|
||||
constructor() {
|
||||
this.logger = (0, debug_1.default)('axm:features:metrics');
|
||||
}
|
||||
init(options) {
|
||||
if (typeof options !== 'object')
|
||||
options = {};
|
||||
this.logger('init');
|
||||
for (let availableMetric of availableMetrics) {
|
||||
const metric = new availableMetric.module();
|
||||
let config = undefined;
|
||||
if (typeof availableMetric.optionsPath !== 'string') {
|
||||
config = {};
|
||||
}
|
||||
else if (availableMetric.optionsPath === '.') {
|
||||
config = options;
|
||||
}
|
||||
else {
|
||||
config = (0, featureManager_1.getObjectAtPath)(options, availableMetric.optionsPath);
|
||||
}
|
||||
metric.init(config);
|
||||
availableMetric.instance = metric;
|
||||
}
|
||||
}
|
||||
get(name) {
|
||||
const metric = availableMetrics.find(metric => metric.name === name);
|
||||
if (metric === undefined)
|
||||
return undefined;
|
||||
return metric.instance;
|
||||
}
|
||||
destroy() {
|
||||
this.logger('destroy');
|
||||
for (let availableMetric of availableMetrics) {
|
||||
if (availableMetric.instance === undefined)
|
||||
continue;
|
||||
availableMetric.instance.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.MetricsFeature = MetricsFeature;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0cmljcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9mZWF0dXJlcy9tZXRyaWNzLnRzIl0sIm5hbWVzIjp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tRQUMxQyxPQUFPLE1BQU0sQ0FBQyxRQUFRLENBQUE7SUFDeEIsQ0FBQztJQUVELE9BQU87UUFDTCxJQUFJLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQ3RCLEtBQUssSUFBSSxlQUFlLElBQUksZ0JBQWdCLEVBQUUsQ0FBQztZQUM3QyxJQUFJLGVBQWUsQ0FBQyxRQUFRLEtBQUssU0FBUztnQkFBRSxTQUFRO1lBQ3BELGVBQWUsQ0FBQyxRQUFRLENBQUMsT0FBTyxFQUFFLENBQUE7UUFDcEMsQ0FBQztJQUNILENBQUM7Q0FDRjtBQXZDRCx3Q0F1Q0MifQ==
|
||||
23
api.hyungi.net/node_modules/@pm2/io/build/main/features/notify.d.ts
generated
vendored
Normal file
23
api.hyungi.net/node_modules/@pm2/io/build/main/features/notify.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Feature } from '../featureManager';
|
||||
export declare class NotifyOptions {
|
||||
catchExceptions: boolean;
|
||||
}
|
||||
export declare class ErrorContext {
|
||||
http?: Object;
|
||||
custom?: Object;
|
||||
}
|
||||
export declare class NotifyFeature implements Feature {
|
||||
private logger;
|
||||
private transport;
|
||||
private cache;
|
||||
private stackParser;
|
||||
init(options?: NotifyOptions): any;
|
||||
destroy(): void;
|
||||
getSafeError(err: any): Error;
|
||||
notifyError(err: Error | string | {}, context?: ErrorContext): any;
|
||||
private onUncaughtException;
|
||||
private onUnhandledRejection;
|
||||
private catchAll;
|
||||
expressErrorHandler(): (err: any, req: any, res: any, next: any) => any;
|
||||
koaErrorHandler(): (ctx: any, next: any) => Promise<void>;
|
||||
}
|
||||
225
api.hyungi.net/node_modules/@pm2/io/build/main/features/notify.js
generated
vendored
Normal file
225
api.hyungi.net/node_modules/@pm2/io/build/main/features/notify.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
api.hyungi.net/node_modules/@pm2/io/build/main/features/profiling.d.ts
generated
vendored
Normal file
18
api.hyungi.net/node_modules/@pm2/io/build/main/features/profiling.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Feature } from '../featureManager';
|
||||
export interface ProfilerType {
|
||||
init(): void;
|
||||
register(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
export declare class ProfilingConfig {
|
||||
cpuJS: boolean;
|
||||
heapSnapshot: boolean;
|
||||
heapSampling: boolean;
|
||||
implementation?: string;
|
||||
}
|
||||
export declare class ProfilingFeature implements Feature {
|
||||
private profiler;
|
||||
private logger;
|
||||
init(config?: ProfilingConfig | boolean): any;
|
||||
destroy(): void;
|
||||
}
|
||||
69
api.hyungi.net/node_modules/@pm2/io/build/main/features/profiling.js
generated
vendored
Normal file
69
api.hyungi.net/node_modules/@pm2/io/build/main/features/profiling.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ProfilingFeature = exports.ProfilingConfig = void 0;
|
||||
const addonProfiler_1 = require("../profilers/addonProfiler");
|
||||
const inspectorProfiler_1 = require("../profilers/inspectorProfiler");
|
||||
const constants_1 = require("../constants");
|
||||
const Debug = require("debug");
|
||||
class ProfilingConfig {
|
||||
}
|
||||
exports.ProfilingConfig = ProfilingConfig;
|
||||
const defaultProfilingConfig = {
|
||||
cpuJS: true,
|
||||
heapSnapshot: true,
|
||||
heapSampling: true,
|
||||
implementation: 'both'
|
||||
};
|
||||
const disabledProfilingConfig = {
|
||||
cpuJS: false,
|
||||
heapSnapshot: false,
|
||||
heapSampling: false,
|
||||
implementation: 'none'
|
||||
};
|
||||
class ProfilingFeature {
|
||||
constructor() {
|
||||
this.logger = Debug('axm:features:profiling');
|
||||
}
|
||||
init(config) {
|
||||
if (config === true) {
|
||||
config = defaultProfilingConfig;
|
||||
}
|
||||
else if (config === false) {
|
||||
config = disabledProfilingConfig;
|
||||
}
|
||||
else if (config === undefined) {
|
||||
config = defaultProfilingConfig;
|
||||
}
|
||||
if (process.env.PM2_PROFILING_FORCE_FALLBACK === 'true') {
|
||||
config.implementation = 'addon';
|
||||
}
|
||||
if (config.implementation === undefined || config.implementation === 'both') {
|
||||
config.implementation = (0, constants_1.canUseInspector)() === true ? 'inspector' : 'addon';
|
||||
}
|
||||
switch (config.implementation) {
|
||||
case 'inspector': {
|
||||
this.logger('using inspector implementation');
|
||||
this.profiler = new inspectorProfiler_1.default();
|
||||
break;
|
||||
}
|
||||
case 'addon': {
|
||||
this.logger('using addon implementation');
|
||||
this.profiler = new addonProfiler_1.default();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return this.logger(`Invalid profiler implementation choosen: ${config.implementation}`);
|
||||
}
|
||||
}
|
||||
this.logger('init');
|
||||
this.profiler.init();
|
||||
}
|
||||
destroy() {
|
||||
this.logger('destroy');
|
||||
if (this.profiler === undefined)
|
||||
return;
|
||||
this.profiler.destroy();
|
||||
}
|
||||
}
|
||||
exports.ProfilingFeature = ProfilingFeature;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsaW5nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2ZlYXR1cmVzL3Byb2ZpbGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSw4REFBc0Q7QUFDdEQsc0VBQThEO0FBQzlELDRDQUE4QztBQUM5QywrQkFBOEI7QUFROUIsTUFBYSxlQUFlO0NBSzNCO0FBTEQsMENBS0M7QUFFRCxNQUFNLHNCQUFzQixHQUFvQjtJQUM5QyxLQUFLLEVBQUUsSUFBSTtJQUNYLFlBQVksRUFBRSxJQUFJO0lBQ2xCLFlBQVksRUFBRSxJQUFJO0lBQ2xCLGNBQWMsRUFBRSxNQUFNO0NBQ3ZCLENBQUE7QUFFRCxNQUFNLHVCQUF1QixHQUFvQjtJQUMvQyxLQUFLLEVBQUUsS0FBSztJQUNaLFlBQVksRUFBRSxL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TtnQkFDN0MsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLDJCQUFpQixFQUFFLENBQUE7Z0JBQ3ZDLE1BQUs7WUFDUCxDQUFDO1lBQ0QsS0FBSyxPQUFPLENBQUMsQ0FBQyxDQUFDO2dCQUNiLElBQUksQ0FBQyxNQUFNLENBQUMsNEJBQTRCLENBQUMsQ0FBQTtnQkFDekMsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLHVCQUFhLEVBQUUsQ0FBQTtnQkFDbkMsTUFBSztZQUNQLENBQUM7WUFDRCxPQUFPLENBQUMsQ0FBQyxDQUFDO2dCQUNSLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyw0Q0FBNEMsTUFBTSxDQUFDLGNBQWMsRUFBRSxDQUFDLENBQUE7WUFDekYsQ0FBQztRQUNILENBQUM7UUFDRCxJQUFJLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxDQUFBO1FBQ25CLElBQUksQ0FBQyxRQUFRLENBQUMsSUFBSSxFQUFFLENBQUE7SUFDdEIsQ0FBQztJQUVELE9BQU87UUFDTCxJQUFJLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQ3RCLElBQUksSUFBSSxDQUFDLFFBQVEsS0FBSyxTQUFTO1lBQUUsT0FBTTtRQUN2QyxJQUFJLENBQUMsUUFBUSxDQUFDLE9BQU8sRUFBRSxDQUFBO0lBQ3pCLENBQUM7Q0FDRjtBQS9DRCw0Q0ErQ0MifQ==
|
||||
3
api.hyungi.net/node_modules/@pm2/io/build/main/index.d.ts
generated
vendored
Normal file
3
api.hyungi.net/node_modules/@pm2/io/build/main/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import PMX from './pmx';
|
||||
declare const io: PMX;
|
||||
export = io;
|
||||
8
api.hyungi.net/node_modules/@pm2/io/build/main/index.js
generated
vendored
Normal file
8
api.hyungi.net/node_modules/@pm2/io/build/main/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
const pmx_1 = require("./pmx");
|
||||
const IO_KEY = Symbol.for('@pm2/io');
|
||||
const isAlreadyHere = (Object.getOwnPropertySymbols(global).indexOf(IO_KEY) > -1);
|
||||
const io = isAlreadyHere ? global[IO_KEY] : new pmx_1.default().init();
|
||||
global[IO_KEY] = io;
|
||||
module.exports = io;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLCtCQUF1QjtBQUV2QixNQUFNLE1BQU0sR0FBRyxNQUFNLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBQ3BDLE1BQU0sYUFBYSxHQUFHLENBQUMsTUFBTSxDQUFDLHFCQUFxQixDQUFDLE1BQU0sQ0FBQyxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFBO0FBRWpGLE1BQU0sRUFBRSxHQUFRLGFBQWEsQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBUSxDQUFDLENBQUMsQ0FBQyxJQUFJLGFBQUcsRUFBRSxDQUFDLElBQUksRUFBRSxDQUFBO0FBQ3hFLE1BQU0sQ0FBQyxNQUFNLENBQUMsR0FBRyxFQUFFLENBQUE7QUFFbkIsaUJBQVMsRUFBRSxDQUFBIn0=
|
||||
17
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/eventLoopMetrics.d.ts
generated
vendored
Normal file
17
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/eventLoopMetrics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { MetricInterface } from '../features/metrics';
|
||||
export declare class EventLoopMetricOption {
|
||||
eventLoopActive: boolean;
|
||||
eventLoopDelay: boolean;
|
||||
}
|
||||
export default class EventLoopHandlesRequestsMetric implements MetricInterface {
|
||||
private metricService;
|
||||
private logger;
|
||||
private requestTimer;
|
||||
private handleTimer;
|
||||
private delayTimer;
|
||||
private delayLoopInterval;
|
||||
private runtimeStatsService;
|
||||
private handle;
|
||||
init(config?: EventLoopMetricOption | boolean): any;
|
||||
destroy(): void;
|
||||
}
|
||||
129
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/eventLoopMetrics.js
generated
vendored
Normal file
129
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/eventLoopMetrics.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/httpMetrics.d.ts
generated
vendored
Normal file
18
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/httpMetrics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { MetricInterface } from '../features/metrics';
|
||||
export declare class HttpMetricsConfig {
|
||||
http: boolean;
|
||||
}
|
||||
export default class HttpMetrics implements MetricInterface {
|
||||
private defaultConf;
|
||||
private metrics;
|
||||
private logger;
|
||||
private metricService;
|
||||
private modules;
|
||||
private hooks;
|
||||
init(config?: HttpMetricsConfig | boolean): any;
|
||||
private registerHttpMetric;
|
||||
private registerHttpsMetric;
|
||||
destroy(): void;
|
||||
private hookHttp;
|
||||
private hookRequire;
|
||||
}
|
||||
179
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/httpMetrics.js
generated
vendored
Normal file
179
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/httpMetrics.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/network.d.ts
generated
vendored
Normal file
15
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/network.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { MetricInterface } from '../features/metrics';
|
||||
export declare class NetworkTrafficConfig {
|
||||
upload: boolean;
|
||||
download: boolean;
|
||||
}
|
||||
export default class NetworkMetric implements MetricInterface {
|
||||
private metricService;
|
||||
private timer;
|
||||
private logger;
|
||||
private socketProto;
|
||||
init(config?: NetworkTrafficConfig | boolean): any;
|
||||
destroy(): void;
|
||||
private catchDownload;
|
||||
private catchUpload;
|
||||
}
|
||||
122
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/network.js
generated
vendored
Normal file
122
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/network.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NetworkTrafficConfig = void 0;
|
||||
const netModule = require("net");
|
||||
const metrics_1 = require("../services/metrics");
|
||||
const Debug = require("debug");
|
||||
const meter_1 = require("../utils/metrics/meter");
|
||||
const shimmer = require("shimmer");
|
||||
const serviceManager_1 = require("../serviceManager");
|
||||
class NetworkTrafficConfig {
|
||||
}
|
||||
exports.NetworkTrafficConfig = NetworkTrafficConfig;
|
||||
const defaultConfig = {
|
||||
upload: false,
|
||||
download: false
|
||||
};
|
||||
const allEnabled = {
|
||||
upload: true,
|
||||
download: true
|
||||
};
|
||||
class NetworkMetric {
|
||||
constructor() {
|
||||
this.logger = Debug('axm:features:metrics:network');
|
||||
}
|
||||
init(config) {
|
||||
if (config === false)
|
||||
return;
|
||||
if (config === true) {
|
||||
config = allEnabled;
|
||||
}
|
||||
if (config === undefined) {
|
||||
config = defaultConfig;
|
||||
}
|
||||
this.metricService = serviceManager_1.ServiceManager.get('metrics');
|
||||
if (this.metricService === undefined) {
|
||||
return this.logger(`Failed to load metric service`);
|
||||
}
|
||||
if (config.download === true) {
|
||||
this.catchDownload();
|
||||
}
|
||||
if (config.upload === true) {
|
||||
this.catchUpload();
|
||||
}
|
||||
this.logger('init');
|
||||
}
|
||||
destroy() {
|
||||
if (this.timer !== undefined) {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
if (this.socketProto !== undefined && this.socketProto !== null) {
|
||||
shimmer.unwrap(this.socketProto, 'read');
|
||||
shimmer.unwrap(this.socketProto, 'write');
|
||||
}
|
||||
this.logger('destroy');
|
||||
}
|
||||
catchDownload() {
|
||||
if (this.metricService === undefined)
|
||||
return this.logger(`Failed to load metric service`);
|
||||
const downloadMeter = new meter_1.default({});
|
||||
this.metricService.registerMetric({
|
||||
name: 'Network In',
|
||||
id: 'internal/network/in',
|
||||
historic: true,
|
||||
type: metrics_1.MetricType.meter,
|
||||
implementation: downloadMeter,
|
||||
unit: 'kb/s',
|
||||
handler: function () {
|
||||
return Math.floor(this.implementation.val() / 1024 * 1000) / 1000;
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
const property = netModule.Socket.prototype.read;
|
||||
const isWrapped = property && property.__wrapped === true;
|
||||
if (isWrapped) {
|
||||
return this.logger(`Already patched socket read, canceling`);
|
||||
}
|
||||
shimmer.wrap(netModule.Socket.prototype, 'read', function (original) {
|
||||
return function () {
|
||||
this.on('data', (data) => {
|
||||
if (typeof data.length === 'number') {
|
||||
downloadMeter.mark(data.length);
|
||||
}
|
||||
});
|
||||
return original.apply(this, arguments);
|
||||
};
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
catchUpload() {
|
||||
if (this.metricService === undefined)
|
||||
return this.logger(`Failed to load metric service`);
|
||||
const uploadMeter = new meter_1.default();
|
||||
this.metricService.registerMetric({
|
||||
name: 'Network Out',
|
||||
id: 'internal/network/out',
|
||||
type: metrics_1.MetricType.meter,
|
||||
historic: true,
|
||||
implementation: uploadMeter,
|
||||
unit: 'kb/s',
|
||||
handler: function () {
|
||||
return Math.floor(this.implementation.val() / 1024 * 1000) / 1000;
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
const property = netModule.Socket.prototype.write;
|
||||
const isWrapped = property && property.__wrapped === true;
|
||||
if (isWrapped) {
|
||||
return this.logger(`Already patched socket write, canceling`);
|
||||
}
|
||||
shimmer.wrap(netModule.Socket.prototype, 'write', function (original) {
|
||||
return function (data) {
|
||||
if (typeof data.length === 'number') {
|
||||
uploadMeter.mark(data.length);
|
||||
}
|
||||
return original.apply(this, arguments);
|
||||
};
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
exports.default = NetworkMetric;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmV0d29yay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tZXRyaWNzL25ldHdvcmsudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsaUNBQWdDO0FBQ2hDLGlEQUErRDtBQUUvRCwrQkFBOEI7QUFDOUIsa0RBQTBDO0FBQzFDLG1DQUFrQztBQUNsQyxzREFBa0Q7QUFFbEQsTUFBYSxvQkFBb0I7Q0FHaEM7QUFIRCxvREFHQztBQUVELE1BQU0sYUFBYSxHQUF5QjtJQUMxQyxNQUFNLEVBQUUsS0FBSztJQUNiLFFBQVEsRUFBRSxLQUFLO0NBQ2hCLENBQUE7QUFFRCxNQUFNLFVBQVUsR0FBeUI7SUFDdkMsTUFBTSxFQUFFLElBQUk7SUFDWixRQUFRLEVBQUUsSUFBSTtDQUNmLENBQUE7QUFFRCxNQUFxQixhQUFhO0lBQWxDO1FBR1UsV0FBTSxHQUFhLEtBQUssQ0FBQyw4QkFBOEIsQ0FBQyxDQUFBO0lBMkdsRSxDQUFDO0lBeEdDLElBQUksQ0FBRSxNQUF1QztRQUMzQyxJQUFJLE1BQU0sS0FBSyxLQUFLO1lBQUUsT0FBTTtRQUM1QixJQUFJLE1BQU0sS0FBSyxJQUFJLEVBQUUsQ0FBQztZQUNwQixNQUFNLEdBQUcsVUFBVSxDQUFBO1FBQ3JCLENBQUM7UUFDRCxJQUFJLE1BQU0sS0FBSyxTQUFTLEVBQUUsQ0FBQztZQUN6QixNQUFNLEdBQUcsYUFBYSxDQUFBO1FBQ3hCLENBQUM7UUFFR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FBUSxHQUFHLFNBQVMsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQTtZQUVqRCxNQUFNLFNBQVMsR0FBRyxRQUFRLElBQUksUUFBUSxDQUFDLFNBQVMsS0FBSyxJQUFJLENBQUE7WUFDekQsSUFBSSxTQUFTLEVBQUUsQ0FBQztnQkFDZCxPQUFPLElBQUksQ0FBQyxNQUFNLENBQUMseUNBQXlDLENBQUMsQ0FBQTtZQUMvRCxDQUFDO1lBQ0QsT0FBTyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLFNBQVMsRUFBRSxPQUFPLEVBQUUsVUFBVSxRQUFRO2dCQUNsRSxPQUFPLFVBQVUsSUFBSTtvQkFDbkIsSUFBSSxPQUFPLElBQUksQ0FBQyxNQUFNLEtBQUssUUFBUSxFQUFFLENBQUM7d0JBQ3BDLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFBO29CQUMvQixDQUFDO29CQUNELE9BQU8sUUFBUSxDQUFDLEtBQUssQ0FBQyxJQUFJLEVBQUUsU0FBUyxDQUFDLENBQUE7Z0JBQ3hDLENBQUMsQ0FBQTtZQUNILENBQUMsQ0FBQyxDQUFBO1FBQ0osQ0FBQyxFQUFFLEdBQUcsQ0FBQyxDQUFBO0lBQ1QsQ0FBQztDQUNGO0FBOUdELGdDQThHQyJ9
|
||||
16
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/runtime.d.ts
generated
vendored
Normal file
16
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/runtime.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { MetricInterface } from '../features/metrics';
|
||||
export declare class RuntimeMetricsOptions {
|
||||
gcOldPause: boolean;
|
||||
gcNewPause: boolean;
|
||||
pageFaults: boolean;
|
||||
contextSwitchs: boolean;
|
||||
}
|
||||
export default class RuntimeMetrics implements MetricInterface {
|
||||
private metricService;
|
||||
private logger;
|
||||
private runtimeStatsService;
|
||||
private handle;
|
||||
private metrics;
|
||||
init(config?: RuntimeMetricsOptions | boolean): any;
|
||||
destroy(): void;
|
||||
}
|
||||
154
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/runtime.js
generated
vendored
Normal file
154
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/runtime.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
23
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/v8.d.ts
generated
vendored
Normal file
23
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/v8.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { MetricInterface } from '../features/metrics';
|
||||
export declare class V8MetricsConfig {
|
||||
new_space: boolean;
|
||||
old_space: boolean;
|
||||
map_space: boolean;
|
||||
code_space: boolean;
|
||||
large_object_space: boolean;
|
||||
heap_total_size: boolean;
|
||||
heap_used_size: boolean;
|
||||
heap_used_percent: boolean;
|
||||
}
|
||||
export default class V8Metric implements MetricInterface {
|
||||
private timer;
|
||||
private TIME_INTERVAL;
|
||||
private metricService;
|
||||
private logger;
|
||||
private metricStore;
|
||||
private unitKB;
|
||||
private metricsDefinitions;
|
||||
init(config?: V8MetricsConfig | boolean): any;
|
||||
destroy(): void;
|
||||
private formatMiBytes;
|
||||
}
|
||||
101
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/v8.js
generated
vendored
Normal file
101
api.hyungi.net/node_modules/@pm2/io/build/main/metrics/v8.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.V8MetricsConfig = void 0;
|
||||
const v8 = require("v8");
|
||||
const debug_1 = require("debug");
|
||||
const serviceManager_1 = require("../serviceManager");
|
||||
class V8MetricsConfig {
|
||||
}
|
||||
exports.V8MetricsConfig = V8MetricsConfig;
|
||||
const defaultOptions = {
|
||||
new_space: false,
|
||||
old_space: false,
|
||||
map_space: false,
|
||||
code_space: false,
|
||||
large_object_space: false,
|
||||
heap_total_size: true,
|
||||
heap_used_size: true,
|
||||
heap_used_percent: true
|
||||
};
|
||||
class V8Metric {
|
||||
constructor() {
|
||||
this.TIME_INTERVAL = 800;
|
||||
this.logger = (0, debug_1.default)('axm:features:metrics:v8');
|
||||
this.metricStore = new Map();
|
||||
this.unitKB = 'MiB';
|
||||
this.metricsDefinitions = {
|
||||
total_heap_size: {
|
||||
name: 'Heap Size',
|
||||
id: 'internal/v8/heap/total',
|
||||
unit: this.unitKB,
|
||||
historic: true
|
||||
},
|
||||
heap_used_percent: {
|
||||
name: 'Heap Usage',
|
||||
id: 'internal/v8/heap/usage',
|
||||
unit: '%',
|
||||
historic: true
|
||||
},
|
||||
used_heap_size: {
|
||||
name: 'Used Heap Size',
|
||||
id: 'internal/v8/heap/used',
|
||||
unit: this.unitKB,
|
||||
historic: true
|
||||
}
|
||||
};
|
||||
}
|
||||
init(config) {
|
||||
if (config === false)
|
||||
return;
|
||||
if (config === undefined) {
|
||||
config = defaultOptions;
|
||||
}
|
||||
if (config === true) {
|
||||
config = defaultOptions;
|
||||
}
|
||||
this.metricService = serviceManager_1.ServiceManager.get('metrics');
|
||||
if (this.metricService === undefined)
|
||||
return this.logger('Failed to load metric service');
|
||||
this.logger('init');
|
||||
if (!v8.hasOwnProperty('getHeapStatistics')) {
|
||||
return this.logger(`V8.getHeapStatistics is not available, aborting`);
|
||||
}
|
||||
for (let metricName in this.metricsDefinitions) {
|
||||
if (config[metricName] === false)
|
||||
continue;
|
||||
const isEnabled = config[metricName];
|
||||
if (isEnabled === false)
|
||||
continue;
|
||||
let metric = this.metricsDefinitions[metricName];
|
||||
this.metricStore.set(metricName, this.metricService.metric(metric));
|
||||
}
|
||||
this.timer = setInterval(() => {
|
||||
const stats = v8.getHeapStatistics();
|
||||
for (let metricName in this.metricsDefinitions) {
|
||||
if (typeof stats[metricName] !== 'number')
|
||||
continue;
|
||||
const gauge = this.metricStore.get(metricName);
|
||||
if (gauge === undefined)
|
||||
continue;
|
||||
gauge.set(this.formatMiBytes(stats[metricName]));
|
||||
}
|
||||
const usage = (stats.used_heap_size / stats.total_heap_size * 100).toFixed(2);
|
||||
const usageMetric = this.metricStore.get('heap_used_percent');
|
||||
if (usageMetric !== undefined) {
|
||||
usageMetric.set(parseFloat(usage));
|
||||
}
|
||||
}, this.TIME_INTERVAL);
|
||||
this.timer.unref();
|
||||
}
|
||||
destroy() {
|
||||
if (this.timer !== undefined) {
|
||||
clearInterval(this.timer);
|
||||
}
|
||||
this.logger('destroy');
|
||||
}
|
||||
formatMiBytes(val) {
|
||||
return (val / 1024 / 1024).toFixed(2);
|
||||
}
|
||||
}
|
||||
exports.default = V8Metric;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidjguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbWV0cmljcy92OC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5QkFBd0I7QUFHeEIsaUNBQXlCO0FBQ3pCLHNEQUFrRDtBQUlsRCxNQUFhLGVBQWU7Q0FTM0I7QUFURCwwQ0FTQztBQUdELE1BQU0sY0FBYyxHQUFvQjtJQUN0QyxTQUFTLEVBQUUsS0FBSztJQUNoQixTQUFTLEVBQUUsS0FBSztJQUNoQixTQUFTLEVBQUUsS0FBSztJQUNoQixVQUFVLEVBQUUsS0FBSztJQUNqQixrQkFBa0IsRUFBRSxLQUFLO0lBQ3pCLGVBQWUsRUFBRSxJQUFJO0lBQ3JCLGNBQWMsRUFBRSxJQUFJO0lBQ3BCLGlCQUFpQixFQUFFLElBQUk7Q0FDeEIsQ0FBQTtBQUVELE1BQXFCLFFBQVE7SUFBN0I7UUFHVSxrQkFBYSxHQUFXLEdBQUcsQ0FBQTtRQUUzQixXQUFNLEdBQWEsSUFBQSxlQUFLLEVBQUMseUJBQXlCLENBQUMsQ0FBQTtRQU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JCQXFIQyJ9
|
||||
50
api.hyungi.net/node_modules/@pm2/io/build/main/pmx.d.ts
generated
vendored
Normal file
50
api.hyungi.net/node_modules/@pm2/io/build/main/pmx.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { TransportConfig } from './services/transport';
|
||||
import { ErrorContext } from './features/notify';
|
||||
import { Metric, HistogramOptions, MetricBulk } from './services/metrics';
|
||||
import Meter from './utils/metrics/meter';
|
||||
import Histogram from './utils/metrics/histogram';
|
||||
import Gauge from './utils/metrics/gauge';
|
||||
import Counter from './utils/metrics/counter';
|
||||
import { MetricConfig } from './features/metrics';
|
||||
import { ProfilingConfig } from './features/profiling';
|
||||
import { Entrypoint } from './features/entrypoint';
|
||||
export declare class IOConfig {
|
||||
catchExceptions?: boolean;
|
||||
metrics?: MetricConfig;
|
||||
actions?: {
|
||||
eventLoopDump?: boolean;
|
||||
};
|
||||
profiling?: ProfilingConfig | boolean;
|
||||
standalone?: boolean;
|
||||
apmOptions?: TransportConfig;
|
||||
}
|
||||
export declare const defaultConfig: IOConfig;
|
||||
export default class PMX {
|
||||
private initialConfig;
|
||||
private featureManager;
|
||||
private transport;
|
||||
private actionService;
|
||||
private metricService;
|
||||
private runtimeStatsService;
|
||||
private logger;
|
||||
private initialized;
|
||||
Entrypoint: {
|
||||
new (): Entrypoint;
|
||||
};
|
||||
init(config?: IOConfig): this;
|
||||
destroy(): void;
|
||||
getConfig(): IOConfig;
|
||||
notifyError(error: Error | string | {}, context?: ErrorContext): any;
|
||||
metrics(metric: MetricBulk | Array<MetricBulk>): any[];
|
||||
histogram(config: HistogramOptions): Histogram;
|
||||
metric(config: Metric): Gauge;
|
||||
gauge(config: Metric): Gauge;
|
||||
counter(config: Metric): Counter;
|
||||
meter(config: Metric): Meter;
|
||||
action(name: string, opts?: Object, fn?: Function): void;
|
||||
onExit(callback: Function): any;
|
||||
emit(name: string, data: Object): any;
|
||||
initModule(opts: any, cb?: Function): any;
|
||||
expressErrorHandler(): (err: any, req: any, res: any, next: any) => any;
|
||||
koaErrorHandler(): (ctx: any, next: any) => Promise<void>;
|
||||
}
|
||||
275
api.hyungi.net/node_modules/@pm2/io/build/main/pmx.js
generated
vendored
Normal file
275
api.hyungi.net/node_modules/@pm2/io/build/main/pmx.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
16
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/addonProfiler.d.ts
generated
vendored
Normal file
16
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/addonProfiler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ProfilerType } from '../features/profiling';
|
||||
export default class AddonProfiler implements ProfilerType {
|
||||
private profiler;
|
||||
private modules;
|
||||
private actionService;
|
||||
private transport;
|
||||
private currentProfile;
|
||||
private logger;
|
||||
init(): any;
|
||||
register(): any;
|
||||
destroy(): void;
|
||||
private onCPUProfileStart;
|
||||
private onCPUProfileStop;
|
||||
private onHeapdump;
|
||||
private takeSnapshot;
|
||||
}
|
||||
172
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/addonProfiler.js
generated
vendored
Normal file
172
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/addonProfiler.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/inspectorProfiler.d.ts
generated
vendored
Normal file
18
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/inspectorProfiler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ProfilerType } from '../features/profiling';
|
||||
export default class InspectorProfiler implements ProfilerType {
|
||||
private profiler;
|
||||
private actionService;
|
||||
private transport;
|
||||
private currentProfile;
|
||||
private logger;
|
||||
private isNode11;
|
||||
init(): any;
|
||||
register(): any;
|
||||
destroy(): void;
|
||||
private onHeapProfileStart;
|
||||
private onHeapProfileStop;
|
||||
private onCPUProfileStart;
|
||||
private onCPUProfileStop;
|
||||
private onHeapdump;
|
||||
takeSnapshot(): Promise<unknown>;
|
||||
}
|
||||
268
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/inspectorProfiler.js
generated
vendored
Normal file
268
api.hyungi.net/node_modules/@pm2/io/build/main/profilers/inspectorProfiler.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
api.hyungi.net/node_modules/@pm2/io/build/main/serviceManager.d.ts
generated
vendored
Normal file
7
api.hyungi.net/node_modules/@pm2/io/build/main/serviceManager.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export declare class Service {
|
||||
}
|
||||
export declare class ServiceManager {
|
||||
static get(serviceName: string): any | undefined;
|
||||
static set(serviceName: string, service: Service): Map<string, any>;
|
||||
static reset(serviceName: string): boolean;
|
||||
}
|
||||
20
api.hyungi.net/node_modules/@pm2/io/build/main/serviceManager.js
generated
vendored
Normal file
20
api.hyungi.net/node_modules/@pm2/io/build/main/serviceManager.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ServiceManager = exports.Service = void 0;
|
||||
const services = new Map();
|
||||
class Service {
|
||||
}
|
||||
exports.Service = Service;
|
||||
class ServiceManager {
|
||||
static get(serviceName) {
|
||||
return services.get(serviceName);
|
||||
}
|
||||
static set(serviceName, service) {
|
||||
return services.set(serviceName, service);
|
||||
}
|
||||
static reset(serviceName) {
|
||||
return services.delete(serviceName);
|
||||
}
|
||||
}
|
||||
exports.ServiceManager = ServiceManager;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZU1hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2VydmljZU1hbmFnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQ0EsTUFBTSxRQUFRLEdBQXFCLElBQUksR0FBRyxFQUFlLENBQUE7QUFFekQsTUFBYSxPQUFPO0NBQUc7QUFBdkIsMEJBQXVCO0FBRXZCLE1BQWEsY0FBYztJQUVsQixNQUFNLENBQUMsR0FBRyxDQUFFLFdBQW1CO1FBQ3BDLE9BQU8sUUFBUSxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQTtJQUNsQyxDQUFDO0lBRU0sTUFBTSxDQUFDLEdBQUcsQ0FBRSxXQUFtQixFQUFFLE9BQWdCO1FBQ3RELE9BQU8sUUFBUSxDQUFDLEdBQUcsQ0FBQyxXQUFXLEVBQUUsT0FBTyxDQUFDLENBQUE7SUFDM0MsQ0FBQztJQUVNLE1BQU0sQ0FBQyxLQUFLLENBQUUsV0FBbUI7UUFDdEMsT0FBTyxRQUFRLENBQUMsTUFBTSxDQUFDLFdBQVcsQ0FBQyxDQUFBO0lBQ3JDLENBQUM7Q0FDRjtBQWJELHdDQWFDIn0=
|
||||
20
api.hyungi.net/node_modules/@pm2/io/build/main/services/actions.d.ts
generated
vendored
Normal file
20
api.hyungi.net/node_modules/@pm2/io/build/main/services/actions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export declare class Action {
|
||||
handler: Function;
|
||||
name: string;
|
||||
type: string;
|
||||
isScoped: boolean;
|
||||
callback?: Function;
|
||||
arity: number;
|
||||
opts: Object | null | undefined;
|
||||
}
|
||||
export declare class ActionService {
|
||||
private timer;
|
||||
private transport;
|
||||
private actions;
|
||||
private logger;
|
||||
private listener;
|
||||
init(): void;
|
||||
destroy(): void;
|
||||
registerAction(actionName?: string, opts?: Object | undefined | Function, handler?: Function): void;
|
||||
scopedAction(actionName?: string, handler?: Function): any;
|
||||
}
|
||||
147
api.hyungi.net/node_modules/@pm2/io/build/main/services/actions.js
generated
vendored
Normal file
147
api.hyungi.net/node_modules/@pm2/io/build/main/services/actions.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
api.hyungi.net/node_modules/@pm2/io/build/main/services/inspector.d.ts
generated
vendored
Normal file
9
api.hyungi.net/node_modules/@pm2/io/build/main/services/inspector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/// <reference types="node" />
|
||||
import * as inspector from 'inspector';
|
||||
export declare class InspectorService {
|
||||
private session;
|
||||
private logger;
|
||||
init(): inspector.Session;
|
||||
getSession(): inspector.Session;
|
||||
destroy(): void;
|
||||
}
|
||||
43
api.hyungi.net/node_modules/@pm2/io/build/main/services/inspector.js
generated
vendored
Normal file
43
api.hyungi.net/node_modules/@pm2/io/build/main/services/inspector.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InspectorService = void 0;
|
||||
const inspector = require("inspector");
|
||||
const debug_1 = require("debug");
|
||||
class InspectorService {
|
||||
constructor() {
|
||||
this.session = null;
|
||||
this.logger = (0, debug_1.default)('axm:services:inspector');
|
||||
}
|
||||
init() {
|
||||
this.logger(`Creating new inspector session`);
|
||||
this.session = new inspector.Session();
|
||||
this.session.connect();
|
||||
this.logger('Connected to inspector');
|
||||
this.session.post('Profiler.enable');
|
||||
this.session.post('HeapProfiler.enable');
|
||||
return this.session;
|
||||
}
|
||||
getSession() {
|
||||
if (this.session === null) {
|
||||
this.session = this.init();
|
||||
return this.session;
|
||||
}
|
||||
else {
|
||||
return this.session;
|
||||
}
|
||||
}
|
||||
destroy() {
|
||||
if (this.session !== null) {
|
||||
this.session.post('Profiler.disable');
|
||||
this.session.post('HeapProfiler.disable');
|
||||
this.session.disconnect();
|
||||
this.session = null;
|
||||
}
|
||||
else {
|
||||
this.logger('No open session');
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.InspectorService = InspectorService;
|
||||
module.exports = InspectorService;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zcGVjdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NlcnZpY2VzL2luc3BlY3Rvci50cyJdLCJ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QUksQ0FBQyxrQkFBa0IsQ0FBQyxDQUFBO1lBQ3JDLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLHNCQUFzQixDQUFDLENBQUE7WUFDekMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLEVBQUUsQ0FBQTtZQUN6QixJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQTtRQUNyQixDQUFDO2FBQU0sQ0FBQztZQUNOLElBQUksQ0FBQyxNQUFNLENBQUMsaUJBQWlCLENBQUMsQ0FBQTtRQUNoQyxDQUFDO0lBQ0gsQ0FBQztDQUNGO0FBbENELDRDQWtDQztBQUVELE1BQU0sQ0FBQyxPQUFPLEdBQUcsZ0JBQWdCLENBQUEifQ==
|
||||
63
api.hyungi.net/node_modules/@pm2/io/build/main/services/metrics.d.ts
generated
vendored
Normal file
63
api.hyungi.net/node_modules/@pm2/io/build/main/services/metrics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import Meter from '../utils/metrics/meter';
|
||||
import Counter from '../utils/metrics/counter';
|
||||
import Histogram from '../utils/metrics/histogram';
|
||||
import { Service } from '../serviceManager';
|
||||
import Gauge from '../utils/metrics/gauge';
|
||||
export declare enum MetricType {
|
||||
'meter' = "meter",
|
||||
'histogram' = "histogram",
|
||||
'counter' = "counter",
|
||||
'gauge' = "gauge",
|
||||
'metric' = "metric"
|
||||
}
|
||||
export declare enum MetricMeasurements {
|
||||
'min' = "min",
|
||||
'max' = "max",
|
||||
'sum' = "sum",
|
||||
'count' = "count",
|
||||
'variance' = "variance",
|
||||
'mean' = "mean",
|
||||
'stddev' = "stddev",
|
||||
'median' = "median",
|
||||
'p75' = "p75",
|
||||
'p95' = "p95",
|
||||
'p99' = "p99",
|
||||
'p999' = "p999"
|
||||
}
|
||||
export interface InternalMetric {
|
||||
name?: string;
|
||||
type?: MetricType;
|
||||
id?: string;
|
||||
historic?: boolean;
|
||||
unit?: string;
|
||||
handler: Function;
|
||||
implementation: any;
|
||||
value?: number;
|
||||
}
|
||||
export declare class Metric {
|
||||
name?: string;
|
||||
id?: string;
|
||||
historic?: boolean;
|
||||
unit?: string;
|
||||
value?: () => number;
|
||||
}
|
||||
export declare class MetricBulk extends Metric {
|
||||
type: MetricType;
|
||||
}
|
||||
export declare class HistogramOptions extends Metric {
|
||||
measurement: MetricMeasurements;
|
||||
}
|
||||
export declare class MetricService implements Service {
|
||||
private metrics;
|
||||
private timer;
|
||||
private transport;
|
||||
private logger;
|
||||
init(): void;
|
||||
registerMetric(metric: InternalMetric): void;
|
||||
meter(opts: Metric): Meter;
|
||||
counter(opts: Metric): Counter;
|
||||
histogram(opts: HistogramOptions): Histogram;
|
||||
metric(opts: Metric): Gauge;
|
||||
deleteMetric(name: string): boolean;
|
||||
destroy(): void;
|
||||
}
|
||||
187
api.hyungi.net/node_modules/@pm2/io/build/main/services/metrics.js
generated
vendored
Normal file
187
api.hyungi.net/node_modules/@pm2/io/build/main/services/metrics.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
api.hyungi.net/node_modules/@pm2/io/build/main/services/runtimeStats.d.ts
generated
vendored
Normal file
10
api.hyungi.net/node_modules/@pm2/io/build/main/services/runtimeStats.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { EventEmitter2 } from 'eventemitter2';
|
||||
export declare class RuntimeStatsService extends EventEmitter2 {
|
||||
private logger;
|
||||
private handle;
|
||||
private noduleInstance;
|
||||
private enabled;
|
||||
init(): any;
|
||||
isEnabled(): boolean;
|
||||
destroy(): void;
|
||||
}
|
||||
50
api.hyungi.net/node_modules/@pm2/io/build/main/services/runtimeStats.js
generated
vendored
Normal file
50
api.hyungi.net/node_modules/@pm2/io/build/main/services/runtimeStats.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RuntimeStatsService = void 0;
|
||||
const debug_1 = require("debug");
|
||||
const module_1 = require("../utils/module");
|
||||
const eventemitter2_1 = require("eventemitter2");
|
||||
class RuntimeStatsService extends eventemitter2_1.EventEmitter2 {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.logger = (0, debug_1.default)('axm:services:runtimeStats');
|
||||
this.enabled = false;
|
||||
}
|
||||
init() {
|
||||
this.logger('init');
|
||||
if (process.env.PM2_APM_DISABLE_RUNTIME_STATS === 'true') {
|
||||
return this.logger('disabling service because of the environment flag');
|
||||
}
|
||||
const modulePath = module_1.default.detectModule('@pm2/node-runtime-stats');
|
||||
if (typeof modulePath !== 'string')
|
||||
return;
|
||||
const RuntimeStats = module_1.default.loadModule(modulePath);
|
||||
if (RuntimeStats instanceof Error) {
|
||||
return this.logger(`Failed to require module @pm2/node-runtime-stats: ${RuntimeStats.message}`);
|
||||
}
|
||||
this.noduleInstance = new RuntimeStats({
|
||||
delay: 1000
|
||||
});
|
||||
this.logger('starting runtime stats');
|
||||
this.noduleInstance.start();
|
||||
this.handle = (data) => {
|
||||
this.logger('received runtime stats', data);
|
||||
this.emit('data', data);
|
||||
};
|
||||
this.noduleInstance.on('sense', this.handle);
|
||||
this.enabled = true;
|
||||
}
|
||||
isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
destroy() {
|
||||
if (this.noduleInstance !== undefined && this.noduleInstance !== null) {
|
||||
this.logger('removing listener on runtime stats service');
|
||||
this.noduleInstance.removeListener('sense', this.handle);
|
||||
this.noduleInstance.stop();
|
||||
}
|
||||
this.logger('destroy');
|
||||
}
|
||||
}
|
||||
exports.RuntimeStatsService = RuntimeStatsService;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVudGltZVN0YXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3J1bnRpbWVTdGF0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxZQUFZLENBQUE7OztBQUV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DQUFDLElBQUksRUFBRSxFQUFFO1lBQ3JCLElBQUksQ0FBQyxNQUFNLENBQUMsd0JBQXdCLEVBQUUsSUFBSSxDQUFDLENBQUE7WUFDM0MsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLEVBQUUsSUFBSSxDQUFDLENBQUE7UUFDekIsQ0FBQyxDQUFBO1FBR0QsSUFBSSxDQUFDLGNBQWMsQ0FBQyxFQUFFLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQTtRQUM1QyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQTtJQUNyQixDQUFDO0lBS0QsU0FBUztRQUNQLE9BQU8sSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUNyQixDQUFDO0lBRUQsT0FBTztRQUNMLElBQUksSUFBSSxDQUFDLGNBQWMsS0FBSyxTQUFTLElBQUksSUFBSSxDQUFDLGNBQWMsS0FBSyxJQUFJLEVBQUUsQ0FBQztZQUN0RSxJQUFJLENBQUMsTUFBTSxDQUFDLDRDQUE0QyxDQUFDLENBQUE7WUFDekQsSUFBSSxDQUFDLGNBQWMsQ0FBQyxjQUFjLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQTtZQUN4RCxJQUFJLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSxDQUFBO1FBQzVCLENBQUM7UUFDRCxJQUFJLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3hCLENBQUM7Q0FDRjtBQWxERCxrREFrREMifQ==
|
||||
22
api.hyungi.net/node_modules/@pm2/io/build/main/services/transport.d.ts
generated
vendored
Normal file
22
api.hyungi.net/node_modules/@pm2/io/build/main/services/transport.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Action } from './actions';
|
||||
import { InternalMetric } from './metrics';
|
||||
import { EventEmitter2 } from 'eventemitter2';
|
||||
export declare class TransportConfig {
|
||||
publicKey: string;
|
||||
secretKey: string;
|
||||
appName: string;
|
||||
serverName?: string;
|
||||
sendLogs?: Boolean;
|
||||
logFilter?: string | RegExp;
|
||||
disableLogs?: Boolean;
|
||||
proxy?: string;
|
||||
}
|
||||
export interface Transport extends EventEmitter2 {
|
||||
init: (config: TransportConfig) => Transport;
|
||||
destroy: () => void;
|
||||
send: (channel: string, payload: Object) => void;
|
||||
addAction: (action: Action) => void;
|
||||
setMetrics: (metrics: InternalMetric[]) => void;
|
||||
setOptions: (options: any) => void;
|
||||
}
|
||||
export declare function createTransport(name: string, config: TransportConfig): Transport;
|
||||
14
api.hyungi.net/node_modules/@pm2/io/build/main/services/transport.js
generated
vendored
Normal file
14
api.hyungi.net/node_modules/@pm2/io/build/main/services/transport.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createTransport = exports.TransportConfig = void 0;
|
||||
const IPCTransport_1 = require("../transports/IPCTransport");
|
||||
class TransportConfig {
|
||||
}
|
||||
exports.TransportConfig = TransportConfig;
|
||||
function createTransport(name, config) {
|
||||
const transport = new IPCTransport_1.IPCTransport();
|
||||
transport.init(config);
|
||||
return transport;
|
||||
}
|
||||
exports.createTransport = createTransport;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNwb3J0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3RyYW5zcG9ydC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFHQSw2REFBeUQ7QUFJekQsTUFBYSxlQUFlO0NBMEMzQjtBQTFDRCwwQ0EwQ0M7QUFnQ0QsU0FBZ0IsZUFBZSxDQUFFLElBQVksRUFBRSxNQUF1QjtJQUNwRSxNQUFNLFNBQVMsR0FBRyxJQUFJLDJCQUFZLEVBQUUsQ0FBQTtJQUNwQyxTQUFTLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3RCLE9BQU8sU0FBUyxDQUFBO0FBZWxCLENBQUM7QUFsQkQsMENBa0JDIn0=
|
||||
17
api.hyungi.net/node_modules/@pm2/io/build/main/transports/IPCTransport.d.ts
generated
vendored
Normal file
17
api.hyungi.net/node_modules/@pm2/io/build/main/transports/IPCTransport.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Transport, TransportConfig } from '../services/transport';
|
||||
import { Action } from '../services/actions';
|
||||
import { InternalMetric } from '../services/metrics';
|
||||
import { EventEmitter2 } from 'eventemitter2';
|
||||
export declare class IPCTransport extends EventEmitter2 implements Transport {
|
||||
private initiated;
|
||||
private logger;
|
||||
private onMessage;
|
||||
private autoExitHandle;
|
||||
init(config?: TransportConfig): Transport;
|
||||
private autoExitHook;
|
||||
setMetrics(metrics: InternalMetric[]): void;
|
||||
addAction(action: Action): void;
|
||||
setOptions(options: any): -1 | undefined;
|
||||
send(channel: any, payload: any): -1 | undefined;
|
||||
destroy(): void;
|
||||
}
|
||||
103
api.hyungi.net/node_modules/@pm2/io/build/main/transports/IPCTransport.js
generated
vendored
Normal file
103
api.hyungi.net/node_modules/@pm2/io/build/main/transports/IPCTransport.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IPCTransport = void 0;
|
||||
const Debug = require("debug");
|
||||
const eventemitter2_1 = require("eventemitter2");
|
||||
const cluster = require("cluster");
|
||||
class IPCTransport extends eventemitter2_1.EventEmitter2 {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.initiated = false;
|
||||
this.logger = Debug('axm:transport:ipc');
|
||||
}
|
||||
init(config) {
|
||||
this.logger('Init new transport service');
|
||||
if (this.initiated === true) {
|
||||
console.error(`Trying to re-init the transport, please avoid`);
|
||||
return this;
|
||||
}
|
||||
this.initiated = true;
|
||||
this.logger('Agent launched');
|
||||
this.onMessage = (data) => {
|
||||
this.logger(`Received reverse message from IPC`);
|
||||
this.emit('data', data);
|
||||
};
|
||||
process.on('message', this.onMessage);
|
||||
if (cluster.isWorker === false) {
|
||||
this.autoExitHook();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
autoExitHook() {
|
||||
this.autoExitHandle = setInterval(() => {
|
||||
let currentProcess = (cluster.isWorker) ? cluster.worker.process : process;
|
||||
if (currentProcess._getActiveHandles().length === 3) {
|
||||
let handlers = currentProcess._getActiveHandles().map(h => h.constructor.name);
|
||||
if (handlers.includes('Pipe') === true &&
|
||||
handlers.includes('Socket') === true) {
|
||||
process.removeListener('message', this.onMessage);
|
||||
let tmp = setTimeout(_ => {
|
||||
this.logger(`Still alive, listen back to IPC`);
|
||||
process.on('message', this.onMessage);
|
||||
}, 200);
|
||||
tmp.unref();
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
this.autoExitHandle.unref();
|
||||
}
|
||||
setMetrics(metrics) {
|
||||
const serializedMetric = metrics.reduce((object, metric) => {
|
||||
if (typeof metric.name !== 'string')
|
||||
return object;
|
||||
object[metric.name] = {
|
||||
historic: metric.historic,
|
||||
unit: metric.unit,
|
||||
type: metric.id,
|
||||
value: metric.value
|
||||
};
|
||||
return object;
|
||||
}, {});
|
||||
this.send('axm:monitor', serializedMetric);
|
||||
}
|
||||
addAction(action) {
|
||||
this.logger(`Add action: ${action.name}:${action.type}`);
|
||||
this.send('axm:action', {
|
||||
action_name: action.name,
|
||||
action_type: action.type,
|
||||
arity: action.arity,
|
||||
opts: action.opts
|
||||
});
|
||||
}
|
||||
setOptions(options) {
|
||||
this.logger(`Set options: [${Object.keys(options).join(',')}]`);
|
||||
return this.send('axm:option:configuration', options);
|
||||
}
|
||||
send(channel, payload) {
|
||||
if (typeof process.send !== 'function')
|
||||
return -1;
|
||||
if (process.connected === false) {
|
||||
console.error('Process disconnected from parent! (not connected)');
|
||||
return process.exit(1);
|
||||
}
|
||||
try {
|
||||
process.send({ type: channel, data: payload });
|
||||
}
|
||||
catch (err) {
|
||||
this.logger('Process disconnected from parent !');
|
||||
this.logger(err);
|
||||
return process.exit(1);
|
||||
}
|
||||
}
|
||||
destroy() {
|
||||
if (this.onMessage !== undefined) {
|
||||
process.removeListener('message', this.onMessage);
|
||||
}
|
||||
if (this.autoExitHandle !== undefined) {
|
||||
clearInterval(this.autoExitHandle);
|
||||
}
|
||||
this.logger('destroy');
|
||||
}
|
||||
}
|
||||
exports.IPCTransport = IPCTransport;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSVBDVHJhbnNwb3J0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3RyYW5zcG9ydHMvSVBDVHJhbnNwb3J0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLCtCQUE4QjtBQUc5QixpREFBNkM7QUFDN0MsbUNBQWtDO0FBRWxDLE1BQWEsWUFBYSxTQUFRLDZCQUFhO0lBQS9DOztRQUVVLGNBQVMsR0FBWSxLQUFLLENBQUE7UUFDMUIsV0FBTSxHQUFhLEtBQUssQ0FBQyxtQkFBbUIsQ0FBQyxDQUFBO0lBd0d2RCxDQUFDO0lBcEdDLElBQUksQ0FBRSxNQUF3QjtRQUM1QixJQUFJLENBQUMsTUFBTSxDQUFDLDRCQUE0QixDQUFDLENBQUE7UUFDekMsSUFBSSxJQUFJLENBQUMsU0FBUyxLQUFLLElBQUksRUFBRSxDQUFDO1lBQzVCLE9BQU8sQ0FBQyxLQUFLLENBQUMsK0NBQStDLENBQUMsQ0FBQTtZQUM5RCxPQUFPLElBQUksQ0FBQTtRQUNiLENBQUM7UUFDRCxJQUFJLENBQUMsU0FBUyxHQUFHLElBQUksQ0FBQTtRQUNyQixJQUFJLENBQUMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLENBQUE7UUFDN0IsSUFBSSxDQUFDLFNBQVMsR0FB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UFDLEVBQUUsSUFBSSxFQUFFLE9BQU8sRUFBRSxJQUFJLEVBQUUsT0FBTyxFQUFFLENBQUMsQ0FBQTtRQUNoRCxDQUFDO1FBQUMsT0FBTyxHQUFHLEVBQUUsQ0FBQztZQUNiLElBQUksQ0FBQyxNQUFNLENBQUMsb0NBQW9DLENBQUMsQ0FBQTtZQUNqRCxJQUFJLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1lBQ2hCLE9BQU8sT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQTtRQUN4QixDQUFDO0lBQ0gsQ0FBQztJQUVELE9BQU87UUFDTCxJQUFJLElBQUksQ0FBQyxTQUFTLEtBQUssU0FBUyxFQUFFLENBQUM7WUFDakMsT0FBTyxDQUFDLGNBQWMsQ0FBQyxTQUFTLEVBQUUsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQ25ELENBQUM7UUFDRCxJQUFJLElBQUksQ0FBQyxjQUFjLEtBQUssU0FBUyxFQUFFLENBQUM7WUFDdEMsYUFBYSxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQTtRQUNwQyxDQUFDO1FBQ0QsSUFBSSxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUN4QixDQUFDO0NBQ0Y7QUEzR0Qsb0NBMkdDIn0=
|
||||
0
api.hyungi.net/node_modules/@pm2/io/build/main/transports/WebsocketTransport.d.ts
generated
vendored
Normal file
0
api.hyungi.net/node_modules/@pm2/io/build/main/transports/WebsocketTransport.d.ts
generated
vendored
Normal file
1
api.hyungi.net/node_modules/@pm2/io/build/main/transports/WebsocketTransport.js
generated
vendored
Normal file
1
api.hyungi.net/node_modules/@pm2/io/build/main/transports/WebsocketTransport.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiV2Vic29ja2V0VHJhbnNwb3J0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3RyYW5zcG9ydHMvV2Vic29ja2V0VHJhbnNwb3J0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
||||
16
api.hyungi.net/node_modules/@pm2/io/build/main/utils/BinaryHeap.d.ts
generated
vendored
Normal file
16
api.hyungi.net/node_modules/@pm2/io/build/main/utils/BinaryHeap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export default class BinaryHeap {
|
||||
private _elements;
|
||||
constructor(options: any);
|
||||
add(): void;
|
||||
first(): any;
|
||||
removeFirst(): any;
|
||||
clone(): BinaryHeap;
|
||||
toSortedArray(): any[];
|
||||
toArray(): never[];
|
||||
size(): any;
|
||||
_bubble(bubbleIndex: any): void;
|
||||
_sink(sinkIndex: any): void;
|
||||
_parentIndex(index: any): number;
|
||||
_childIndexes(index: any): number[];
|
||||
_score(element: any): any;
|
||||
}
|
||||
109
api.hyungi.net/node_modules/@pm2/io/build/main/utils/BinaryHeap.js
generated
vendored
Normal file
109
api.hyungi.net/node_modules/@pm2/io/build/main/utils/BinaryHeap.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class BinaryHeap {
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
this._elements = options.elements || [];
|
||||
this._score = options.score || this._score;
|
||||
}
|
||||
add() {
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
const element = arguments[i];
|
||||
this._elements.push(element);
|
||||
this._bubble(this._elements.length - 1);
|
||||
}
|
||||
}
|
||||
first() {
|
||||
return this._elements[0];
|
||||
}
|
||||
removeFirst() {
|
||||
const root = this._elements[0];
|
||||
const last = this._elements.pop();
|
||||
if (this._elements.length > 0) {
|
||||
this._elements[0] = last;
|
||||
this._sink(0);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
clone() {
|
||||
return new BinaryHeap({
|
||||
elements: this.toArray(),
|
||||
score: this._score
|
||||
});
|
||||
}
|
||||
toSortedArray() {
|
||||
const array = [];
|
||||
const clone = this.clone();
|
||||
while (true) {
|
||||
const element = clone.removeFirst();
|
||||
if (element === undefined)
|
||||
break;
|
||||
array.push(element);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
toArray() {
|
||||
return [].concat(this._elements);
|
||||
}
|
||||
size() {
|
||||
return this._elements.length;
|
||||
}
|
||||
_bubble(bubbleIndex) {
|
||||
const bubbleElement = this._elements[bubbleIndex];
|
||||
const bubbleScore = this._score(bubbleElement);
|
||||
while (bubbleIndex > 0) {
|
||||
const parentIndex = this._parentIndex(bubbleIndex);
|
||||
const parentElement = this._elements[parentIndex];
|
||||
const parentScore = this._score(parentElement);
|
||||
if (bubbleScore <= parentScore)
|
||||
break;
|
||||
this._elements[parentIndex] = bubbleElement;
|
||||
this._elements[bubbleIndex] = parentElement;
|
||||
bubbleIndex = parentIndex;
|
||||
}
|
||||
}
|
||||
_sink(sinkIndex) {
|
||||
const sinkElement = this._elements[sinkIndex];
|
||||
const sinkScore = this._score(sinkElement);
|
||||
const length = this._elements.length;
|
||||
while (true) {
|
||||
let swapIndex;
|
||||
let swapScore;
|
||||
let swapElement = null;
|
||||
const childIndexes = this._childIndexes(sinkIndex);
|
||||
for (let i = 0; i < childIndexes.length; i++) {
|
||||
const childIndex = childIndexes[i];
|
||||
if (childIndex >= length)
|
||||
break;
|
||||
const childElement = this._elements[childIndex];
|
||||
const childScore = this._score(childElement);
|
||||
if (childScore > sinkScore) {
|
||||
if (swapScore === undefined || swapScore < childScore) {
|
||||
swapIndex = childIndex;
|
||||
swapScore = childScore;
|
||||
swapElement = childElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (swapIndex === undefined)
|
||||
break;
|
||||
this._elements[swapIndex] = sinkElement;
|
||||
this._elements[sinkIndex] = swapElement;
|
||||
sinkIndex = swapIndex;
|
||||
}
|
||||
}
|
||||
_parentIndex(index) {
|
||||
return Math.floor((index - 1) / 2);
|
||||
}
|
||||
_childIndexes(index) {
|
||||
return [
|
||||
2 * index + 1,
|
||||
2 * index + 2
|
||||
];
|
||||
}
|
||||
_score(element) {
|
||||
return element.valueOf();
|
||||
}
|
||||
}
|
||||
exports.default = BinaryHeap;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmluYXJ5SGVhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy91dGlscy9CaW5hcnlIZWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsTUFBcUIsVUFBVTtJQUk3QixZQUFhLE9BQU87UUFDbEIsT0FBTyxHQUFHLE9BQU8sSUFBSSxFQUFFLENBQUE7UUFFdkIsSUFBSSxDQUFDLFNBQVMsR0FBRyxPQUFPLENBQUMsUUFBUSxJQUFJLEVBQUUsQ0FBQTtRQUN2QyxJQUFJLENBQUMsTUFBTSxHQUFHLE9BQU8sQ0FBQyxLQUFLLElBQUksSUFBSSxDQUFDLE1BQU0sQ0FBQTtJQUM1QyxDQUFDO0lBRUQsR0FBRztRQUNELEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxTQUFTLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFLENBQUM7WUFDMUMsTUFBTSxPQUFPLEdBQUcsU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFBO1lBRTVCLElBQUksQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFBO1lBQzVCLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUE7UUFDekMsQ0FBQztJQUNILENBQUM7SUFFRCxLQUFLO1FBQ0gsT0FBTyxJQUFJLENBQUMsU0F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LFNBQVMsQ0FBQyxTQUFTLENBQUMsR0FBRyxXQUFXLENBQUE7WUFDdkMsU0FBUyxHQUFHLFNBQVMsQ0FBQTtRQUN2QixDQUFDO0lBQ0gsQ0FBQztJQUVELFlBQVksQ0FBRSxLQUFLO1FBQ2pCLE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLEtBQUssR0FBRyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQTtJQUNwQyxDQUFDO0lBRUQsYUFBYSxDQUFFLEtBQUs7UUFDbEIsT0FBTztZQUNMLENBQUMsR0FBRyxLQUFLLEdBQUcsQ0FBQztZQUNiLENBQUMsR0FBRyxLQUFLLEdBQUcsQ0FBQztTQUNkLENBQUE7SUFDSCxDQUFDO0lBRUQsTUFBTSxDQUFFLE9BQU87UUFDYixPQUFPLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQTtJQUMxQixDQUFDO0NBQ0Y7QUFwSUQsNkJBb0lDIn0=
|
||||
21
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EDS.d.ts
generated
vendored
Normal file
21
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EDS.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export default class ExponentiallyDecayingSample {
|
||||
private RESCALE_INTERVAL;
|
||||
private ALPHA;
|
||||
private SIZE;
|
||||
private _elements;
|
||||
private _rescaleInterval;
|
||||
private _alpha;
|
||||
private _size;
|
||||
private _landmark;
|
||||
private _nextRescale;
|
||||
private _mean;
|
||||
constructor(options?: any);
|
||||
update(value: any, timestamp?: any): void;
|
||||
toSortedArray(): any;
|
||||
toArray(): any;
|
||||
_weight(age: any): number;
|
||||
_priority(age: any): number;
|
||||
_random(): number;
|
||||
_rescale(now: any): void;
|
||||
avg(now: any): number;
|
||||
}
|
||||
93
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EDS.js
generated
vendored
Normal file
93
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EDS.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const BinaryHeap_1 = require("./BinaryHeap");
|
||||
const units_1 = require("./units");
|
||||
class ExponentiallyDecayingSample {
|
||||
constructor(options) {
|
||||
this.RESCALE_INTERVAL = 1 * units_1.default.HOURS;
|
||||
this.ALPHA = 0.015;
|
||||
this.SIZE = 1028;
|
||||
options = options || {};
|
||||
this._elements = new BinaryHeap_1.default({
|
||||
score: function (element) {
|
||||
return -element.priority;
|
||||
}
|
||||
});
|
||||
this._rescaleInterval = options.rescaleInterval || this.RESCALE_INTERVAL;
|
||||
this._alpha = options.alpha || this.ALPHA;
|
||||
this._size = options.size || this.SIZE;
|
||||
this._random = options.random || this._random;
|
||||
this._landmark = null;
|
||||
this._nextRescale = null;
|
||||
this._mean = null;
|
||||
}
|
||||
update(value, timestamp) {
|
||||
const now = Date.now();
|
||||
if (!this._landmark) {
|
||||
this._landmark = now;
|
||||
this._nextRescale = this._landmark + this._rescaleInterval;
|
||||
}
|
||||
timestamp = timestamp || now;
|
||||
const newSize = this._elements.size() + 1;
|
||||
const element = {
|
||||
priority: this._priority(timestamp - this._landmark),
|
||||
value: value
|
||||
};
|
||||
if (newSize <= this._size) {
|
||||
this._elements.add(element);
|
||||
}
|
||||
else if (element.priority > this._elements.first().priority) {
|
||||
this._elements.removeFirst();
|
||||
this._elements.add(element);
|
||||
}
|
||||
if (now >= this._nextRescale)
|
||||
this._rescale(now);
|
||||
}
|
||||
toSortedArray() {
|
||||
return this._elements
|
||||
.toSortedArray()
|
||||
.map(function (element) {
|
||||
return element.value;
|
||||
});
|
||||
}
|
||||
toArray() {
|
||||
return this._elements
|
||||
.toArray()
|
||||
.map(function (element) {
|
||||
return element.value;
|
||||
});
|
||||
}
|
||||
_weight(age) {
|
||||
return Math.exp(this._alpha * (age / 1000));
|
||||
}
|
||||
_priority(age) {
|
||||
return this._weight(age) / this._random();
|
||||
}
|
||||
_random() {
|
||||
return Math.random();
|
||||
}
|
||||
_rescale(now) {
|
||||
now = now || Date.now();
|
||||
const self = this;
|
||||
const oldLandmark = this._landmark;
|
||||
this._landmark = now || Date.now();
|
||||
this._nextRescale = now + this._rescaleInterval;
|
||||
const factor = self._priority(-(self._landmark - oldLandmark));
|
||||
this._elements
|
||||
.toArray()
|
||||
.forEach(function (element) {
|
||||
element.priority *= factor;
|
||||
});
|
||||
}
|
||||
avg(now) {
|
||||
let sum = 0;
|
||||
this._elements
|
||||
.toArray()
|
||||
.forEach(function (element) {
|
||||
sum += element.value;
|
||||
});
|
||||
return (sum / this._elements.size());
|
||||
}
|
||||
}
|
||||
exports.default = ExponentiallyDecayingSample;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRURTLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3V0aWxzL0VEUy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZDQUFxQztBQUNyQyxtQ0FBMkI7QUFFM0IsTUFBcUIsMkJBQTJCO0lBYTlDLFlBQWEsT0FBUTtRQVpiLHFCQUFnQixHQUFHLENBQUMsR0FBRyxlQUFLLENBQUMsS0FBSyxDQUFBO1FBQ2xDLFVBQUssR0FBRyxLQUFLLENBQUE7UUFDYixTQUFJLEdBQUcsSUFBSSxDQUFBO1FBV2pCLE9BQU8sR0FBRyxPQUFPLElBQUksRUFBRSxDQUFBO1FBRXZCLElBQUksQ0FBQyxTQUFTLEdBQUcsSUFBSSxvQkFBVSxDQUFDO1lBQzlCLEtBQUssRUFBRSxVQUFVLE9BQU87Z0JBQ3RCLE9BQU8sQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFBO1lBQzFCLENBQUM7U0FDRixDQUFDLENBQUE7UUFFRixJQUFJLENBQUMsZ0JBQWdCLEdBQUcsT0FBTyxDQUFDLGVBQWUsSUFBSSxJQUFJLENB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FBQyxHQUFHLEdBQUcsSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFBO0lBQ3RDLENBQUM7Q0FDRjtBQWpIRCw4Q0FpSEMifQ==
|
||||
12
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EWMA.d.ts
generated
vendored
Normal file
12
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EWMA.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export default class ExponentiallyWeightedMovingAverage {
|
||||
private _timePeriod;
|
||||
private _tickInterval;
|
||||
private _alpha;
|
||||
private _count;
|
||||
private _rate;
|
||||
private TICK_INTERVAL;
|
||||
constructor(timePeriod?: number, tickInterval?: number);
|
||||
update(n: any): void;
|
||||
tick(): void;
|
||||
rate(timeUnit: any): number;
|
||||
}
|
||||
26
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EWMA.js
generated
vendored
Normal file
26
api.hyungi.net/node_modules/@pm2/io/build/main/utils/EWMA.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const units_1 = require("./units");
|
||||
class ExponentiallyWeightedMovingAverage {
|
||||
constructor(timePeriod, tickInterval) {
|
||||
this._count = 0;
|
||||
this._rate = 0;
|
||||
this.TICK_INTERVAL = 5 * units_1.default.SECONDS;
|
||||
this._timePeriod = timePeriod || 1 * units_1.default.MINUTES;
|
||||
this._tickInterval = tickInterval || this.TICK_INTERVAL;
|
||||
this._alpha = 1 - Math.exp(-this._tickInterval / this._timePeriod);
|
||||
}
|
||||
update(n) {
|
||||
this._count += n;
|
||||
}
|
||||
tick() {
|
||||
const instantRate = this._count / this._tickInterval;
|
||||
this._count = 0;
|
||||
this._rate += (this._alpha * (instantRate - this._rate));
|
||||
}
|
||||
rate(timeUnit) {
|
||||
return (this._rate || 0) * timeUnit;
|
||||
}
|
||||
}
|
||||
exports.default = ExponentiallyWeightedMovingAverage;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UMsQ0FBQTtJQUMxRCxDQUFDO0lBRUQsSUFBSSxDQUFFLFFBQVE7UUFDWixPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssSUFBSSxDQUFDLENBQUMsR0FBRyxRQUFRLENBQUE7SUFDckMsQ0FBQztDQUNGO0FBN0JELHFEQTZCQyJ9
|
||||
13
api.hyungi.net/node_modules/@pm2/io/build/main/utils/autocast.d.ts
generated
vendored
Normal file
13
api.hyungi.net/node_modules/@pm2/io/build/main/utils/autocast.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export default class Autocast {
|
||||
commonStrings: {
|
||||
true: boolean;
|
||||
false: boolean;
|
||||
undefined: undefined;
|
||||
null: null;
|
||||
NaN: number;
|
||||
};
|
||||
process(key: any, value: any, o: any): void;
|
||||
traverse(o: any, func: any): void;
|
||||
autocast(s: any): any;
|
||||
private _cast;
|
||||
}
|
||||
49
api.hyungi.net/node_modules/@pm2/io/build/main/utils/autocast.js
generated
vendored
Normal file
49
api.hyungi.net/node_modules/@pm2/io/build/main/utils/autocast.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class Autocast {
|
||||
constructor() {
|
||||
this.commonStrings = {
|
||||
'true': true,
|
||||
'false': false,
|
||||
'undefined': undefined,
|
||||
'null': null,
|
||||
'NaN': NaN
|
||||
};
|
||||
}
|
||||
process(key, value, o) {
|
||||
if (typeof (value) === 'object')
|
||||
return;
|
||||
o[key] = this._cast(value);
|
||||
}
|
||||
traverse(o, func) {
|
||||
for (let i in o) {
|
||||
func.apply(this, [i, o[i], o]);
|
||||
if (o[i] !== null && typeof (o[i]) === 'object') {
|
||||
this.traverse(o[i], func);
|
||||
}
|
||||
}
|
||||
}
|
||||
autocast(s) {
|
||||
if (typeof (s) === 'object') {
|
||||
this.traverse(s, this.process);
|
||||
return s;
|
||||
}
|
||||
return this._cast(s);
|
||||
}
|
||||
_cast(s) {
|
||||
let key;
|
||||
if (s instanceof Date)
|
||||
return s;
|
||||
if (typeof s === 'boolean')
|
||||
return s;
|
||||
if (!isNaN(s))
|
||||
return Number(s);
|
||||
for (key in this.commonStrings) {
|
||||
if (s === key)
|
||||
return this.commonStrings[key];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
exports.default = Autocast;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0b2Nhc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdXRpbHMvYXV0b2Nhc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFxQixRQUFRO0lBQTdCO1FBSUUsa0JBQWEsR0FBRztZQUNkLE1BQU0sRUFBRSxJQUFJO1lBQ1osT0FBTyxFQUFFLEtBQUs7WUFDZCxXQUFXLEVBQUUsU0FBUztZQUN0QixNQUFNLEVBQUUsSUFBSTtZQUNaLEtBQUssRUFBRSxHQUFHO1NBQ1gsQ0FBQTtJQStDSCxDQUFDO0lBN0NDLE9BQU8sQ0FBRSxHQUFHLEVBQUMsS0FBSyxFQUFFLENBQUM7UUFDbkIsSUFBSSxPQUFNLENBQUMsS0FBSyxDQUFDLEtBQUssUUFBUTtZQUFFLE9BQU07UUFDdEMsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLENBQUE7SUFDNUIsQ0FBQztJQUVELFFBQVEsQ0FBRSxDQUFDLEVBQUMsSUFBSTtRQUNkLEtBQUssSUFBSSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUM7WUFDaEIsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJLEVBQUMsQ0FBQyxDQUFDLEVBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUE7WUFDNUIsSUFBS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kF5REMifQ==
|
||||
10
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/counter.d.ts
generated
vendored
Normal file
10
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/counter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export default class Counter {
|
||||
private _count;
|
||||
private used;
|
||||
constructor(opts?: any);
|
||||
val(): number;
|
||||
inc(n?: number): void;
|
||||
dec(n?: number): void;
|
||||
reset(count?: number): void;
|
||||
isUsed(): boolean;
|
||||
}
|
||||
28
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/counter.js
generated
vendored
Normal file
28
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/counter.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class Counter {
|
||||
constructor(opts) {
|
||||
this.used = false;
|
||||
opts = opts || {};
|
||||
this._count = opts.count || 0;
|
||||
}
|
||||
val() {
|
||||
return this._count;
|
||||
}
|
||||
inc(n) {
|
||||
this.used = true;
|
||||
this._count += (n || 1);
|
||||
}
|
||||
dec(n) {
|
||||
this.used = true;
|
||||
this._count -= (n || 1);
|
||||
}
|
||||
reset(count) {
|
||||
this._count = count || 0;
|
||||
}
|
||||
isUsed() {
|
||||
return this.used;
|
||||
}
|
||||
}
|
||||
exports.default = Counter;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY291bnRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy91dGlscy9tZXRyaWNzL2NvdW50ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFxQixPQUFPO0lBSTFCLFlBQWEsSUFBSztRQUZWLFNBQUksR0FBWSxLQUFLLENBQUE7UUFHM0IsSUFBSSxHQUFHLElBQUksSUFBSSxFQUFFLENBQUE7UUFDakIsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLENBQUMsS0FBSyxJQUFJLENBQUMsQ0FBQTtJQUMvQixDQUFDO0lBRUQsR0FBRztRQUNELE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQTtJQUNwQixDQUFDO0lBRUQsR0FBRyxDQUFFLENBQVU7UUFDYixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQTtRQUNoQixJQUFJLENBQUMsTUFBTSxJQUFJLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFBO0lBQ3pCLENBQUM7SUFFRCxHQUFHLENBQUUsQ0FBVTtRQUNiLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFBO1FBQ2hCLElBQUksQ0FBQyxNQUFNLElBQUksQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUE7SUFDekIsQ0FBQztJQUVELEtBQUssQ0FBRSxLQUFjO1FBQ25CLElBQUksQ0FBQyxNQUFNLEdBQUcsS0FBSyxJQUFJLENBQUMsQ0FBQTtJQUMxQixDQUFDO0lBRUQsTUFBTTtRQUNKLE9BQU8sSUFBSSxDQUFDLElBQUksQ0FBQTtJQUNsQixDQUFDO0NBQ0Y7QUE5QkQsMEJBOEJDIn0=
|
||||
7
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/gauge.d.ts
generated
vendored
Normal file
7
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/gauge.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default class Gauge {
|
||||
private value;
|
||||
private used;
|
||||
val(): number;
|
||||
set(value: any): void;
|
||||
isUsed(): boolean;
|
||||
}
|
||||
20
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/gauge.js
generated
vendored
Normal file
20
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/gauge.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class Gauge {
|
||||
constructor() {
|
||||
this.value = 0;
|
||||
this.used = false;
|
||||
}
|
||||
val() {
|
||||
return this.value;
|
||||
}
|
||||
set(value) {
|
||||
this.used = true;
|
||||
this.value = value;
|
||||
}
|
||||
isUsed() {
|
||||
return this.used;
|
||||
}
|
||||
}
|
||||
exports.default = Gauge;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2F1Z2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdXRpbHMvbWV0cmljcy9nYXVnZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLE1BQXFCLEtBQUs7SUFBMUI7UUFDVSxVQUFLLEdBQUcsQ0FBQyxDQUFBO1FBQ1QsU0FBSSxHQUFHLEtBQUssQ0FBQTtJQWN0QixDQUFDO0lBWkMsR0FBRztRQUNELE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQTtJQUNuQixDQUFDO0lBRUQsR0FBRyxDQUFFLEtBQUs7UUFDUixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQTtRQUNoQixJQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQTtJQUNwQixDQUFDO0lBRUQsTUFBTTtRQUNKLE9BQU8sSUFBSSxDQUFDLElBQUksQ0FBQTtJQUNsQixDQUFDO0NBQ0Y7QUFoQkQsd0JBZ0JDIn0=
|
||||
43
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/histogram.d.ts
generated
vendored
Normal file
43
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/histogram.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
export default class Histogram {
|
||||
private _measurement;
|
||||
private _callFn;
|
||||
private _sample;
|
||||
private _min;
|
||||
private _max;
|
||||
private _count;
|
||||
private _sum;
|
||||
private _varianceM;
|
||||
private _varianceS;
|
||||
private _ema;
|
||||
private used;
|
||||
constructor(opts?: any);
|
||||
update(value: number): void;
|
||||
percentiles(percentiles: any): {};
|
||||
val(): any;
|
||||
getMin(): any;
|
||||
getMax(): any;
|
||||
getSum(): number;
|
||||
getCount(): number;
|
||||
getEma(): number;
|
||||
fullResults(): {
|
||||
min: any;
|
||||
max: any;
|
||||
sum: number;
|
||||
variance: number | null;
|
||||
mean: number;
|
||||
count: number;
|
||||
median: any;
|
||||
p75: any;
|
||||
p95: any;
|
||||
p99: any;
|
||||
p999: any;
|
||||
ema: number;
|
||||
};
|
||||
_updateMin(value: any): void;
|
||||
_updateMax(value: any): void;
|
||||
_updateVariance(value: any): any;
|
||||
_updateEma(value: any): number | undefined;
|
||||
_calculateMean(): number;
|
||||
_calculateVariance(): number | null;
|
||||
isUsed(): boolean;
|
||||
}
|
||||
160
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/histogram.js
generated
vendored
Normal file
160
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/histogram.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/meter.d.ts
generated
vendored
Normal file
12
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/meter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export default class Meter {
|
||||
private _tickInterval;
|
||||
private _samples;
|
||||
private _timeframe;
|
||||
private _rate;
|
||||
private _interval;
|
||||
private used;
|
||||
constructor(opts?: any);
|
||||
mark: (n?: number) => void;
|
||||
val: () => number;
|
||||
isUsed(): boolean;
|
||||
}
|
||||
36
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/meter.js
generated
vendored
Normal file
36
api.hyungi.net/node_modules/@pm2/io/build/main/utils/metrics/meter.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const EWMA_1 = require("../EWMA");
|
||||
const units_1 = require("../units");
|
||||
class Meter {
|
||||
constructor(opts) {
|
||||
this.used = false;
|
||||
this.mark = function (n = 1) {
|
||||
this.used = true;
|
||||
this._rate.update(n);
|
||||
};
|
||||
this.val = function () {
|
||||
return Math.round(this._rate.rate(this._samples * units_1.default.SECONDS) * 100) / 100;
|
||||
};
|
||||
const self = this;
|
||||
if (typeof opts !== 'object') {
|
||||
opts = {};
|
||||
}
|
||||
this._samples = opts.samples || opts.seconds || 1;
|
||||
this._timeframe = opts.timeframe || 60;
|
||||
this._tickInterval = opts.tickInterval || 5 * units_1.default.SECONDS;
|
||||
this._rate = new EWMA_1.default(this._timeframe * units_1.default.SECONDS, this._tickInterval);
|
||||
if (opts.debug && opts.debug === true) {
|
||||
return;
|
||||
}
|
||||
this._interval = setInterval(function () {
|
||||
self._rate.tick();
|
||||
}, this._tickInterval);
|
||||
this._interval.unref();
|
||||
}
|
||||
isUsed() {
|
||||
return this.used;
|
||||
}
|
||||
}
|
||||
exports.default = Meter;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvdXRpbHMvbWV0cmljcy9tZXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGtDQUEwQjtBQUMxQixvQ0FBNEI7QUFFNUIsTUFBcUIsS0FBSztJQVN4QixZQUFhLElBQVU7UUFGZixTQUFJLEdBQVksS0FBSyxDQUFBO1FBMEI3QixTQUFJLEdBQUcsVUFBVSxJQUFZLENBQUM7WUFDNUIsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUE7WUFDaEIsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDdEIsQ0FBQyxDQUFBO1FBRUQsUUFBRyxHQUFHO1lBQ0osT0FBTyxJQUFJLENBQUMsS0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QUE7SUFDeEIsQ0FBQztJQVdELE1BQU07UUFDSixPQUFPLElBQUksQ0FBQyxJQUFJLENBQUE7SUFDbEIsQ0FBQztDQUNGO0FBN0NELHdCQTZDQyJ9
|
||||
4
api.hyungi.net/node_modules/@pm2/io/build/main/utils/miscellaneous.d.ts
generated
vendored
Normal file
4
api.hyungi.net/node_modules/@pm2/io/build/main/utils/miscellaneous.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export default class MiscUtils {
|
||||
static generateUUID(): string;
|
||||
static getValueFromDump(property: any, parentProperty?: any): number;
|
||||
}
|
||||
17
api.hyungi.net/node_modules/@pm2/io/build/main/utils/miscellaneous.js
generated
vendored
Normal file
17
api.hyungi.net/node_modules/@pm2/io/build/main/utils/miscellaneous.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const serviceManager_1 = require("../serviceManager");
|
||||
class MiscUtils {
|
||||
static generateUUID() {
|
||||
return Math.random().toString(36).substr(2, 16);
|
||||
}
|
||||
static getValueFromDump(property, parentProperty) {
|
||||
if (!parentProperty) {
|
||||
parentProperty = 'handles';
|
||||
}
|
||||
const dump = serviceManager_1.ServiceManager.get('eventLoopService').inspector.dump();
|
||||
return dump[parentProperty].hasOwnProperty(property) ? dump[parentProperty][property].length : 0;
|
||||
}
|
||||
}
|
||||
exports.default = MiscUtils;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlzY2VsbGFuZW91cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy91dGlscy9taXNjZWxsYW5lb3VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsc0RBQWtEO0FBRWxELE1BQXFCLFNBQVM7SUFDNUIsTUFBTSxDQUFDLFlBQVk7UUFDakIsT0FBTyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsUUFBUSxDQUFDLEVBQUUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBQUE7SUFDakQsQ0FBQztJQUVELE1BQU0sQ0FBQyxnQkFBZ0IsQ0FBRSxRQUFRLEVBQUUsY0FBZTtRQUNoRCxJQUFJLENBQUMsY0FBYyxFQUFFLENBQUM7WUFDcEIsY0FBYyxHQUFHLFNBQVMsQ0FBQTtRQUM1QixDQUFDO1FBQ0QsTUFBTSxJQUFJLEdBQUcsK0JBQWMsQ0FBQyxHQUFHLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxTQUFTLENBQUMsSUFBSSxFQUFFLENBQUE7UUFDcEUsT0FBTyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsY0FBYyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsY0FBYyxDQUFDLENBQUMsUUFBUSxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFDbEcsQ0FBQztDQUNGO0FBWkQsNEJBWUMifQ==
|
||||
5
api.hyungi.net/node_modules/@pm2/io/build/main/utils/module.d.ts
generated
vendored
Normal file
5
api.hyungi.net/node_modules/@pm2/io/build/main/utils/module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export default class ModuleUtils {
|
||||
static loadModule(modulePath: string, args?: Object): any | Error;
|
||||
static detectModule(moduleName: string): string | null;
|
||||
private static _lookForModule;
|
||||
}
|
||||
53
api.hyungi.net/node_modules/@pm2/io/build/main/utils/module.js
generated
vendored
Normal file
53
api.hyungi.net/node_modules/@pm2/io/build/main/utils/module.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = require("fs");
|
||||
const Debug = require("debug");
|
||||
const path = require("path");
|
||||
const debug = Debug('axm:utils:module');
|
||||
class ModuleUtils {
|
||||
static loadModule(modulePath, args) {
|
||||
let nodule;
|
||||
try {
|
||||
if (args) {
|
||||
nodule = require(modulePath).apply(this, args);
|
||||
}
|
||||
else {
|
||||
nodule = require(modulePath);
|
||||
}
|
||||
debug(`Succesfully required module at path ${modulePath}`);
|
||||
return nodule;
|
||||
}
|
||||
catch (err) {
|
||||
debug(`Failed to load module at path ${modulePath}: ${err.message}`);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
static detectModule(moduleName) {
|
||||
const fakePath = ['./node_modules', '/node_modules'];
|
||||
if (!require.main) {
|
||||
return null;
|
||||
}
|
||||
const paths = typeof require.main.paths === 'undefined' ? fakePath : require.main.paths;
|
||||
const requirePaths = paths.slice();
|
||||
return ModuleUtils._lookForModule(requirePaths, moduleName);
|
||||
}
|
||||
static _lookForModule(requirePaths, moduleName) {
|
||||
const fsConstants = fs.constants || fs;
|
||||
for (let requirePath of requirePaths) {
|
||||
const completePath = path.join(requirePath, moduleName);
|
||||
debug(`Looking for module ${moduleName} in ${completePath}`);
|
||||
try {
|
||||
fs.accessSync(completePath, fsConstants.R_OK);
|
||||
debug(`Found module ${moduleName} in path ${completePath}`);
|
||||
return completePath;
|
||||
}
|
||||
catch (err) {
|
||||
debug(`module ${moduleName} not found in path ${completePath}`);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.default = ModuleUtils;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3V0aWxzL21vZHVsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHlCQUF3QjtBQUN4QiwrQkFBOEI7QUFDOUIsNkJBQTRCO0FBRTVCLE1BQU0sS0FBSyxHQUFHLEtBQUssQ0FBQyxrQkFBa0IsQ0FBQyxDQUFBO0FBRXZDL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BRSxDQUFBO1FBRWxDLE9BQU8sV0FBVyxDQUFDLGNBQWMsQ0FBQyxZQUFZLEVBQUUsVUFBVSxDQUFDLENBQUE7SUFDN0QsQ0FBQztJQUtPLE1BQU0sQ0FBQyxjQUFjLENBQUUsWUFBMkIsRUFBRSxVQUFrQjtRQUU1RSxNQUFNLFdBQVcsR0FBRyxFQUFFLENBQUMsU0FBUyxJQUFJLEVBQUUsQ0FBQTtRQUV0QyxLQUFLLElBQUksV0FBVyxJQUFJLFlBQVksRUFBRSxDQUFDO1lBQ3JDLE1BQU0sWUFBWSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxFQUFFLFVBQVUsQ0FBQyxDQUFBO1lBQ3ZELEtBQUssQ0FBQyxzQkFBc0IsVUFBVSxPQUFPLFlBQVksRUFBRSxDQUFDLENBQUE7WUFDNUQsSUFBSSxDQUFDO2dCQUNILEVBQUUsQ0FBQyxVQUFVLENBQUMsWUFBWSxFQUFFLFdBQVcsQ0FBQyxJQUFJLENBQUMsQ0FBQTtnQkFDN0MsS0FBSyxDQUFDLGdCQUFnQixVQUFVLFlBQVksWUFBWSxFQUFFLENBQUMsQ0FBQTtnQkFDM0QsT0FBTyxZQUFZLENBQUE7WUFDckIsQ0FBQztZQUFDLE9BQU8sR0FBRyxFQUFFLENBQUM7Z0JBQ2IsS0FBSyxDQUFDLFVBQVUsVUFBVSxzQkFBc0IsWUFBWSxFQUFFLENBQUMsQ0FBQTtnQkFDL0QsU0FBUTtZQUNWLENBQUM7UUFDSCxDQUFDO1FBQ0QsT0FBTyxJQUFJLENBQUE7SUFDYixDQUFDO0NBQ0Y7QUF4REQsOEJBd0RDIn0=
|
||||
37
api.hyungi.net/node_modules/@pm2/io/build/main/utils/stackParser.d.ts
generated
vendored
Normal file
37
api.hyungi.net/node_modules/@pm2/io/build/main/utils/stackParser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
export type MissFunction = (key: string) => any;
|
||||
export type CacheOptions = {
|
||||
miss: MissFunction;
|
||||
ttl?: number;
|
||||
};
|
||||
export type StackContext = {
|
||||
callsite: string;
|
||||
context: string;
|
||||
};
|
||||
export type FrameMetadata = {
|
||||
line_number: number;
|
||||
file_name: string;
|
||||
};
|
||||
export declare class Cache {
|
||||
private cache;
|
||||
private ttlCache;
|
||||
private worker;
|
||||
private tllTime;
|
||||
private onMiss;
|
||||
constructor(opts: CacheOptions);
|
||||
workerFn(): void;
|
||||
get(key: string): any;
|
||||
set(key: string, value: any): boolean;
|
||||
reset(): void;
|
||||
}
|
||||
export type StackTraceParserOptions = {
|
||||
cache: Cache;
|
||||
contextSize: number;
|
||||
};
|
||||
export declare class StackTraceParser {
|
||||
private cache;
|
||||
private contextSize;
|
||||
constructor(options: StackTraceParserOptions);
|
||||
isAbsolute(path: any): boolean;
|
||||
parse(stack: FrameMetadata[]): StackContext | null;
|
||||
retrieveContext(error: Error): StackContext | null;
|
||||
}
|
||||
126
api.hyungi.net/node_modules/@pm2/io/build/main/utils/stackParser.js
generated
vendored
Normal file
126
api.hyungi.net/node_modules/@pm2/io/build/main/utils/stackParser.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
74
api.hyungi.net/node_modules/@pm2/io/build/main/utils/transactionAggregator.d.ts
generated
vendored
Normal file
74
api.hyungi.net/node_modules/@pm2/io/build/main/utils/transactionAggregator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
import { EventEmitter2 } from 'eventemitter2';
|
||||
import EWMA from './EWMA';
|
||||
import Histogram from './metrics/histogram';
|
||||
export interface Span {
|
||||
name: string;
|
||||
labels: any;
|
||||
kind: string;
|
||||
startTime: number;
|
||||
min: number;
|
||||
max: number;
|
||||
median: number;
|
||||
}
|
||||
export interface Variance {
|
||||
spans: Span[];
|
||||
count: number;
|
||||
min: number;
|
||||
max: number;
|
||||
median: number;
|
||||
p95: number;
|
||||
}
|
||||
export interface Route {
|
||||
path: string;
|
||||
meta: {
|
||||
min: number;
|
||||
max: number;
|
||||
count: number;
|
||||
meter: number;
|
||||
median: number;
|
||||
p95: number;
|
||||
};
|
||||
variances: Variance[];
|
||||
}
|
||||
export interface Trace {
|
||||
routes: Route[];
|
||||
meta: {
|
||||
trace_count: number;
|
||||
http_meter: number;
|
||||
db_meter: number;
|
||||
http_percentiles: {
|
||||
median: number;
|
||||
p95: number;
|
||||
p99: number;
|
||||
};
|
||||
db_percentiles: any;
|
||||
};
|
||||
}
|
||||
export interface TraceCache {
|
||||
routes: any;
|
||||
meta: {
|
||||
trace_count: number;
|
||||
http_meter: EWMA;
|
||||
db_meter: EWMA;
|
||||
histogram: Histogram;
|
||||
db_histograms: any;
|
||||
};
|
||||
}
|
||||
export declare class TransactionAggregator extends EventEmitter2 {
|
||||
private spanTypes;
|
||||
private cache;
|
||||
private privacyRegex;
|
||||
private worker;
|
||||
init(sendInterval?: number): void;
|
||||
destroy(): void;
|
||||
getAggregation(): TraceCache;
|
||||
validateData(packet: any): boolean;
|
||||
aggregate(packet: any): false | TraceCache;
|
||||
mergeTrace(aggregated: any, trace: any): void;
|
||||
updateSpanDuration(spans: any, newSpans: any): void;
|
||||
compareList(one: any[], two: any[]): boolean;
|
||||
matchPath(path: any, routes: any): any;
|
||||
prepareAggregationforShipping(): Trace;
|
||||
isIdentifier(id: any): boolean;
|
||||
censorSpans(spans: any): any;
|
||||
}
|
||||
318
api.hyungi.net/node_modules/@pm2/io/build/main/utils/transactionAggregator.js
generated
vendored
Normal file
318
api.hyungi.net/node_modules/@pm2/io/build/main/utils/transactionAggregator.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
api.hyungi.net/node_modules/@pm2/io/build/main/utils/units.d.ts
generated
vendored
Normal file
10
api.hyungi.net/node_modules/@pm2/io/build/main/utils/units.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
declare const _default: {
|
||||
NANOSECONDS: number;
|
||||
MICROSECONDS: number;
|
||||
MILLISECONDS: number;
|
||||
SECONDS: number;
|
||||
MINUTES: number;
|
||||
HOURS: number;
|
||||
DAYS: number;
|
||||
};
|
||||
export default _default;
|
||||
16
api.hyungi.net/node_modules/@pm2/io/build/main/utils/units.js
generated
vendored
Normal file
16
api.hyungi.net/node_modules/@pm2/io/build/main/utils/units.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const MILLISECONDS = 1;
|
||||
const SECONDS = 1000 * MILLISECONDS;
|
||||
const MINUTES = 60 * SECONDS;
|
||||
const HOURS = 60 * MINUTES;
|
||||
exports.default = {
|
||||
NANOSECONDS: 1 / (1000 * 1000),
|
||||
MICROSECONDS: 1 / 1000,
|
||||
MILLISECONDS: MILLISECONDS,
|
||||
SECONDS: SECONDS,
|
||||
MINUTES: MINUTES,
|
||||
HOURS: HOURS,
|
||||
DAYS: 24 * HOURS
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidW5pdHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdXRpbHMvdW5pdHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFNLFlBQVksR0FBRyxDQUFDLENBQUE7QUFDdEIsTUFBTSxPQUFPLEdBQUcsSUFBSSxHQUFHLFlBQVksQ0FBQTtBQUNuQyxNQUFNLE9BQU8sR0FBRyxFQUFFLEdBQUcsT0FBTyxDQUFBO0FBQzVCLE1BQU0sS0FBSyxHQUFHLEVBQUUsR0FBRyxPQUFPLENBQUE7QUFFMUIsa0JBQWU7SUFDYixXQUFXLEVBQUUsQ0FBQyxHQUFHLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztJQUM5QixZQUFZLEVBQUUsQ0FBQyxHQUFHLElBQUk7SUFDdEIsWUFBWSxFQUFFLFlBQVk7SUFDMUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsT0FBTyxFQUFFLE9BQU87SUFDaEIsS0FBSyxFQUFFLEtBQUs7SUFDWixJQUFJLEVBQUUsRUFBRSxHQUFHLEtBQUs7Q0FDakIsQ0FBQSJ9
|
||||
27
api.hyungi.net/node_modules/@pm2/io/docker-compose.yml
generated
vendored
Normal file
27
api.hyungi.net/node_modules/@pm2/io/docker-compose.yml
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
mongodb:
|
||||
image: mongo:3.4
|
||||
ports:
|
||||
- "27017:27017"
|
||||
environment:
|
||||
AUTH: "no"
|
||||
redis:
|
||||
image: eywek/redis:5
|
||||
ports:
|
||||
- "6379:6379"
|
||||
mysql:
|
||||
image: mysql:5
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
MYSQL_DATABASE: 'test'
|
||||
MYSQL_ROOT_PASSWORD: 'password'
|
||||
postgres:
|
||||
image: postgres:11
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
POSTGRES_DB: 'test'
|
||||
POSTGRES_PASSWORD: 'password'
|
||||
106
api.hyungi.net/node_modules/@pm2/io/docs/README.md
generated
vendored
Normal file
106
api.hyungi.net/node_modules/@pm2/io/docs/README.md
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
# PM2 APM Architecture
|
||||
|
||||
The APM has been architected for a maximum composability when developing different features, each component have exactly one job and they have access to different low level API (like sendin/receiving data) to be able to do it.
|
||||
|
||||
Here a simple (not exact) architecture diagram:
|
||||
|
||||

|
||||
|
||||
## Concept
|
||||
|
||||
### Manager
|
||||
|
||||
There are two "Manager" in the implementation:
|
||||
- The Service Manager which statically store reference to all services so they are available by other component.
|
||||
- The Feature Manager which handle the configuration and instanciation of each feature.
|
||||
|
||||
### Service
|
||||
|
||||
A service is an internal component designed to group a speficic logic and provide a simple API to do that logic.
|
||||
They should not be accessible to user to allow us to change the low level API without breaking anything.
|
||||
|
||||
### Feature
|
||||
|
||||
Exaclty as it sound, a feature is a component that actually do something, for example:
|
||||
- The tracing feature handle all the tracing infrastructure from the init to sending all trace data.
|
||||
- The notify metrics provide an API to send error to the remote infrastructure
|
||||
|
||||
Each feature expose different methods and there are not exposed by default to the user.
|
||||
|
||||
### Public API
|
||||
|
||||
By public API we mean all the functions that a user can call when instanciating the APM.
|
||||
Each function that need to be exposed is added into the main instance and then use the feature manager to call the actual method implmentation.
|
||||
This design help maintaining backward compatibility at the user level and not in the logic implementation.
|
||||
|
||||
## Services
|
||||
|
||||
### Transport
|
||||
|
||||
The most important service is the Transport service which offer an interface to implement different type of transport. It also provide an API to create a transport instance.
|
||||
|
||||
##### IPC Transport
|
||||
|
||||
This is the default transport and it's based on IPC, a shared file descriptor used to transfer data to and from the PM2 daemon.
|
||||
Every data is sent as specific packet to the PM2 RPC system that will then broadcast them to the agent.
|
||||
See the agent: https://github.com/keymetrics/pm2-io-agent
|
||||
|
||||
##### Websocket Transport
|
||||
|
||||
The websocket transport is the new transporter used when we don't use the PM2 daemon and his agent to send data.
|
||||
It use this agent: https://github.com/keymetrics/pm2-io-agent-node to handle the low level networking to our servers.
|
||||
|
||||
### Metrics
|
||||
|
||||
The metrics service expose method to register metrics that will be sent to the remote endpoint, it then handle:
|
||||
- Fetching the value of the metrics every second, and sending them formatted to the transport service
|
||||
|
||||
### Actions
|
||||
|
||||
The action service, as the metric service, expose an API to register custom action. It handle the listening to the remote connection for new action request, call the actual user function and then send back the user data.
|
||||
|
||||
### Inspector
|
||||
|
||||
This service doesn't do much apart from offering a `inspector` session to every feature that need it. From Node 8 to node 10, there could be only one session in the whole process so this service is made to avoid having two session opened by different features.
|
||||
|
||||
### RuntimeStats
|
||||
|
||||
This service is simply a wrapper to the `@pm2/node-runtime-stats` module that allows to get low level metrics about the node runtime.
|
||||
Since multiple metrics are using it, we made a service out of it so we only have one instance of it.
|
||||
|
||||
## Features
|
||||
|
||||
### Notify
|
||||
|
||||
The `notify` provides 3 API:
|
||||
- `notifyError` to send custom error to the remote server
|
||||
- `expressErrorHandler` which is a express middleware that catch error and send them
|
||||
- `koaErrorHandler` same as express middleware but for koa
|
||||
|
||||
It also handle the `unhandledRejection` and `uncaughtException` error event to also send them. In the case of `uncaughtException`, it also `exit` the process.
|
||||
|
||||
### Profiling
|
||||
|
||||
The profiling feature provide a wrapper on top of two different profilers implementation:
|
||||
- `inspector` based profiling, which is a built-in API for Node 8 to interact with v8 API
|
||||
- `addon` based profiling which is seperate c++ addon that need to be installed, it's only here to support Node 6.
|
||||
|
||||
Both register customs actions with the `ActionService` to when a user can remotely start and stop profiles in their processes.
|
||||
|
||||
### Tracing
|
||||
|
||||
The tracing feature handle the `opencensus` agent which is in `src/census`, for more information about how they works, you should read about [Opencensus Node Agent](https://github.com/census-instrumentation/opencensus-node/)
|
||||
|
||||
We got our own plugins to be able to iterate faster on them and since the opencensus API isn't stable yet, do not break between minor bump of opencensus.
|
||||
We implemented our own exporter that use the `TransportService` to send trace data to the remote server.
|
||||
|
||||
### Metrics
|
||||
|
||||
The Metrics service is implemented as a Manager because it only instanciate different metrics and don't do anything more.
|
||||
Here the current list of metrics implemented:
|
||||
- Event loop Metrics: when the `@pm2/node-runtime-stats` addon is there, it use it to get metrics directly from libuv otherwise it fallback on computing it with javascript.
|
||||
- HTTP Metrics: When the `http` or `https` module is required, add custom listener for request and compute latency/volume for them.
|
||||
- Network Metrics: Patch the `net.Socket` implementation to count how much bytes are sent/received from/to the network
|
||||
- Runtime Metrics: Only available when the `@pm2/node-runtime-stats` is there, it add metrics about the V8 GC and Linux Kernel metrics
|
||||
- V8: Fetch from built-in `v8` module some metrics about heap usage.
|
||||
|
||||
278
api.hyungi.net/node_modules/@pm2/io/node_modules/async/CHANGELOG.md
generated
vendored
Normal file
278
api.hyungi.net/node_modules/@pm2/io/node_modules/async/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
# v2.6.4
|
||||
- Fix potential prototype pollution exploit (#1828)
|
||||
|
||||
# v2.6.3
|
||||
- Updated lodash to squelch a security warning (#1675)
|
||||
|
||||
# v2.6.2
|
||||
- Updated lodash to squelch a security warning (#1620)
|
||||
|
||||
# v2.6.1
|
||||
- Updated lodash to prevent `npm audit` warnings. (#1532, #1533)
|
||||
- Made `async-es` more optimized for webpack users (#1517)
|
||||
- Fixed a stack overflow with large collections and a synchronous iterator (#1514)
|
||||
- Various small fixes/chores (#1505, #1511, #1527, #1530)
|
||||
|
||||
# v2.6.0
|
||||
- Added missing aliases for many methods. Previously, you could not (e.g.) `require('async/find')` or use `async.anyLimit`. (#1483)
|
||||
- Improved `queue` performance. (#1448, #1454)
|
||||
- Add missing sourcemap (#1452, #1453)
|
||||
- Various doc updates (#1448, #1471, #1483)
|
||||
|
||||
# v2.5.0
|
||||
- Added `concatLimit`, the `Limit` equivalent of [`concat`](https://caolan.github.io/async/docs.html#concat) ([#1426](https://github.com/caolan/async/issues/1426), [#1430](https://github.com/caolan/async/pull/1430))
|
||||
- `concat` improvements: it now preserves order, handles falsy values and the `iteratee` callback takes a variable number of arguments ([#1437](https://github.com/caolan/async/issues/1437), [#1436](https://github.com/caolan/async/pull/1436))
|
||||
- Fixed an issue in `queue` where there was a size discrepancy between `workersList().length` and `running()` ([#1428](https://github.com/caolan/async/issues/1428), [#1429](https://github.com/caolan/async/pull/1429))
|
||||
- Various doc fixes ([#1422](https://github.com/caolan/async/issues/1422), [#1424](https://github.com/caolan/async/pull/1424))
|
||||
|
||||
# v2.4.1
|
||||
- Fixed a bug preventing functions wrapped with `timeout()` from being re-used. ([#1418](https://github.com/caolan/async/issues/1418), [#1419](https://github.com/caolan/async/issues/1419))
|
||||
|
||||
# v2.4.0
|
||||
- Added `tryEach`, for running async functions in parallel, where you only expect one to succeed. ([#1365](https://github.com/caolan/async/issues/1365), [#687](https://github.com/caolan/async/issues/687))
|
||||
- Improved performance, most notably in `parallel` and `waterfall` ([#1395](https://github.com/caolan/async/issues/1395))
|
||||
- Added `queue.remove()`, for removing items in a `queue` ([#1397](https://github.com/caolan/async/issues/1397), [#1391](https://github.com/caolan/async/issues/1391))
|
||||
- Fixed using `eval`, preventing Async from running in pages with Content Security Policy ([#1404](https://github.com/caolan/async/issues/1404), [#1403](https://github.com/caolan/async/issues/1403))
|
||||
- Fixed errors thrown in an `asyncify`ed function's callback being caught by the underlying Promise ([#1408](https://github.com/caolan/async/issues/1408))
|
||||
- Fixed timing of `queue.empty()` ([#1367](https://github.com/caolan/async/issues/1367))
|
||||
- Various doc fixes ([#1314](https://github.com/caolan/async/issues/1314), [#1394](https://github.com/caolan/async/issues/1394), [#1412](https://github.com/caolan/async/issues/1412))
|
||||
|
||||
# v2.3.0
|
||||
- Added support for ES2017 `async` functions. Wherever you can pass a Node-style/CPS function that uses a callback, you can also pass an `async` function. Previously, you had to wrap `async` functions with `asyncify`. The caveat is that it will only work if `async` functions are supported natively in your environment, transpiled implementations can't be detected. ([#1386](https://github.com/caolan/async/issues/1386), [#1390](https://github.com/caolan/async/issues/1390))
|
||||
- Small doc fix ([#1392](https://github.com/caolan/async/issues/1392))
|
||||
|
||||
# v2.2.0
|
||||
- Added `groupBy`, and the `Series`/`Limit` equivalents, analogous to [`_.groupBy`](http://lodash.com/docs#groupBy) ([#1364](https://github.com/caolan/async/issues/1364))
|
||||
- Fixed `transform` bug when `callback` was not passed ([#1381](https://github.com/caolan/async/issues/1381))
|
||||
- Added note about `reflect` to `parallel` docs ([#1385](https://github.com/caolan/async/issues/1385))
|
||||
|
||||
# v2.1.5
|
||||
- Fix `auto` bug when function names collided with Array.prototype ([#1358](https://github.com/caolan/async/issues/1358))
|
||||
- Improve some error messages ([#1349](https://github.com/caolan/async/issues/1349))
|
||||
- Avoid stack overflow case in queue
|
||||
- Fixed an issue in `some`, `every` and `find` where processing would continue after the result was determined.
|
||||
- Cleanup implementations of `some`, `every` and `find`
|
||||
|
||||
# v2.1.3
|
||||
- Make bundle size smaller
|
||||
- Create optimized hotpath for `filter` in array case.
|
||||
|
||||
# v2.1.2
|
||||
- Fixed a stackoverflow bug with `detect`, `some`, `every` on large inputs ([#1293](https://github.com/caolan/async/issues/1293)).
|
||||
|
||||
# v2.1.0
|
||||
|
||||
- `retry` and `retryable` now support an optional `errorFilter` function that determines if the `task` should retry on the error ([#1256](https://github.com/caolan/async/issues/1256), [#1261](https://github.com/caolan/async/issues/1261))
|
||||
- Optimized array iteration in `race`, `cargo`, `queue`, and `priorityQueue` ([#1253](https://github.com/caolan/async/issues/1253))
|
||||
- Added alias documentation to doc site ([#1251](https://github.com/caolan/async/issues/1251), [#1254](https://github.com/caolan/async/issues/1254))
|
||||
- Added [BootStrap scrollspy](http://getbootstrap.com/javascript/#scrollspy) to docs to highlight in the sidebar the current method being viewed ([#1289](https://github.com/caolan/async/issues/1289), [#1300](https://github.com/caolan/async/issues/1300))
|
||||
- Various minor doc fixes ([#1263](https://github.com/caolan/async/issues/1263), [#1264](https://github.com/caolan/async/issues/1264), [#1271](https://github.com/caolan/async/issues/1271), [#1278](https://github.com/caolan/async/issues/1278), [#1280](https://github.com/caolan/async/issues/1280), [#1282](https://github.com/caolan/async/issues/1282), [#1302](https://github.com/caolan/async/issues/1302))
|
||||
|
||||
# v2.0.1
|
||||
|
||||
- Significantly optimized all iteration based collection methods such as `each`, `map`, `filter`, etc ([#1245](https://github.com/caolan/async/issues/1245), [#1246](https://github.com/caolan/async/issues/1246), [#1247](https://github.com/caolan/async/issues/1247)).
|
||||
|
||||
# v2.0.0
|
||||
|
||||
Lots of changes here!
|
||||
|
||||
First and foremost, we have a slick new [site for docs](https://caolan.github.io/async/). Special thanks to [**@hargasinski**](https://github.com/hargasinski) for his work converting our old docs to `jsdoc` format and implementing the new website. Also huge ups to [**@ivanseidel**](https://github.com/ivanseidel) for designing our new logo. It was a long process for both of these tasks, but I think these changes turned out extraordinary well.
|
||||
|
||||
The biggest feature is modularization. You can now `require("async/series")` to only require the `series` function. Every Async library function is available this way. You still can `require("async")` to require the entire library, like you could do before.
|
||||
|
||||
We also provide Async as a collection of ES2015 modules. You can now `import {each} from 'async-es'` or `import waterfall from 'async-es/waterfall'`. If you are using only a few Async functions, and are using a ES bundler such as Rollup, this can significantly lower your build size.
|
||||
|
||||
Major thanks to [**@Kikobeats**](github.com/Kikobeats), [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac) for doing the majority of the modularization work, as well as [**@jdalton**](github.com/jdalton) and [**@Rich-Harris**](github.com/Rich-Harris) for advisory work on the general modularization strategy.
|
||||
|
||||
Another one of the general themes of the 2.0 release is standardization of what an "async" function is. We are now more strictly following the node-style continuation passing style. That is, an async function is a function that:
|
||||
|
||||
1. Takes a variable number of arguments
|
||||
2. The last argument is always a callback
|
||||
3. The callback can accept any number of arguments
|
||||
4. The first argument passed to the callback will be treated as an error result, if the argument is truthy
|
||||
5. Any number of result arguments can be passed after the "error" argument
|
||||
6. The callback is called once and exactly once, either on the same tick or later tick of the JavaScript event loop.
|
||||
|
||||
There were several cases where Async accepted some functions that did not strictly have these properties, most notably `auto`, `every`, `some`, `filter`, `reject` and `detect`.
|
||||
|
||||
Another theme is performance. We have eliminated internal deferrals in all cases where they make sense. For example, in `waterfall` and `auto`, there was a `setImmediate` between each task -- these deferrals have been removed. A `setImmediate` call can add up to 1ms of delay. This might not seem like a lot, but it can add up if you are using many Async functions in the course of processing a HTTP request, for example. Nearly all asynchronous functions that do I/O already have some sort of deferral built in, so the extra deferral is unnecessary. The trade-off of this change is removing our built-in stack-overflow defense. Many synchronous callback calls in series can quickly overflow the JS call stack. If you do have a function that is sometimes synchronous (calling its callback on the same tick), and are running into stack overflows, wrap it with `async.ensureAsync()`.
|
||||
|
||||
Another big performance win has been re-implementing `queue`, `cargo`, and `priorityQueue` with [doubly linked lists](https://en.wikipedia.org/wiki/Doubly_linked_list) instead of arrays. This has lead to queues being an order of [magnitude faster on large sets of tasks](https://github.com/caolan/async/pull/1205).
|
||||
|
||||
## New Features
|
||||
|
||||
- Async is now modularized. Individual functions can be `require()`d from the main package. (`require('async/auto')`) ([#984](https://github.com/caolan/async/issues/984), [#996](https://github.com/caolan/async/issues/996))
|
||||
- Async is also available as a collection of ES2015 modules in the new `async-es` package. (`import {forEachSeries} from 'async-es'`) ([#984](https://github.com/caolan/async/issues/984), [#996](https://github.com/caolan/async/issues/996))
|
||||
- Added `race`, analogous to `Promise.race()`. It will run an array of async tasks in parallel and will call its callback with the result of the first task to respond. ([#568](https://github.com/caolan/async/issues/568), [#1038](https://github.com/caolan/async/issues/1038))
|
||||
- Collection methods now accept ES2015 iterators. Maps, Sets, and anything that implements the iterator spec can now be passed directly to `each`, `map`, `parallel`, etc.. ([#579](https://github.com/caolan/async/issues/579), [#839](https://github.com/caolan/async/issues/839), [#1074](https://github.com/caolan/async/issues/1074))
|
||||
- Added `mapValues`, for mapping over the properties of an object and returning an object with the same keys. ([#1157](https://github.com/caolan/async/issues/1157), [#1177](https://github.com/caolan/async/issues/1177))
|
||||
- Added `timeout`, a wrapper for an async function that will make the task time-out after the specified time. ([#1007](https://github.com/caolan/async/issues/1007), [#1027](https://github.com/caolan/async/issues/1027))
|
||||
- Added `reflect` and `reflectAll`, analagous to [`Promise.reflect()`](http://bluebirdjs.com/docs/api/reflect.html), a wrapper for async tasks that always succeeds, by gathering results and errors into an object. ([#942](https://github.com/caolan/async/issues/942), [#1012](https://github.com/caolan/async/issues/1012), [#1095](https://github.com/caolan/async/issues/1095))
|
||||
- `constant` supports dynamic arguments -- it will now always use its last argument as the callback. ([#1016](https://github.com/caolan/async/issues/1016), [#1052](https://github.com/caolan/async/issues/1052))
|
||||
- `setImmediate` and `nextTick` now support arguments to partially apply to the deferred function, like the node-native versions do. ([#940](https://github.com/caolan/async/issues/940), [#1053](https://github.com/caolan/async/issues/1053))
|
||||
- `auto` now supports resolving cyclic dependencies using [Kahn's algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm) ([#1140](https://github.com/caolan/async/issues/1140)).
|
||||
- Added `autoInject`, a relative of `auto` that automatically spreads a task's dependencies as arguments to the task function. ([#608](https://github.com/caolan/async/issues/608), [#1055](https://github.com/caolan/async/issues/1055), [#1099](https://github.com/caolan/async/issues/1099), [#1100](https://github.com/caolan/async/issues/1100))
|
||||
- You can now limit the concurrency of `auto` tasks. ([#635](https://github.com/caolan/async/issues/635), [#637](https://github.com/caolan/async/issues/637))
|
||||
- Added `retryable`, a relative of `retry` that wraps an async function, making it retry when called. ([#1058](https://github.com/caolan/async/issues/1058))
|
||||
- `retry` now supports specifying a function that determines the next time interval, useful for exponential backoff, logging and other retry strategies. ([#1161](https://github.com/caolan/async/issues/1161))
|
||||
- `retry` will now pass all of the arguments the task function was resolved with to the callback ([#1231](https://github.com/caolan/async/issues/1231)).
|
||||
- Added `q.unsaturated` -- callback called when a `queue`'s number of running workers falls below a threshold. ([#868](https://github.com/caolan/async/issues/868), [#1030](https://github.com/caolan/async/issues/1030), [#1033](https://github.com/caolan/async/issues/1033), [#1034](https://github.com/caolan/async/issues/1034))
|
||||
- Added `q.error` -- a callback called whenever a `queue` task calls its callback with an error. ([#1170](https://github.com/caolan/async/issues/1170))
|
||||
- `applyEach` and `applyEachSeries` now pass results to the final callback. ([#1088](https://github.com/caolan/async/issues/1088))
|
||||
|
||||
## Breaking changes
|
||||
|
||||
- Calling a callback more than once is considered an error, and an error will be thrown. This had an explicit breaking change in `waterfall`. If you were relying on this behavior, you should more accurately represent your control flow as an event emitter or stream. ([#814](https://github.com/caolan/async/issues/814), [#815](https://github.com/caolan/async/issues/815), [#1048](https://github.com/caolan/async/issues/1048), [#1050](https://github.com/caolan/async/issues/1050))
|
||||
- `auto` task functions now always take the callback as the last argument. If a task has dependencies, the `results` object will be passed as the first argument. To migrate old task functions, wrap them with [`_.flip`](https://lodash.com/docs#flip) ([#1036](https://github.com/caolan/async/issues/1036), [#1042](https://github.com/caolan/async/issues/1042))
|
||||
- Internal `setImmediate` calls have been refactored away. This may make existing flows vulnerable to stack overflows if you use many synchronous functions in series. Use `ensureAsync` to work around this. ([#696](https://github.com/caolan/async/issues/696), [#704](https://github.com/caolan/async/issues/704), [#1049](https://github.com/caolan/async/issues/1049), [#1050](https://github.com/caolan/async/issues/1050))
|
||||
- `map` used to return an object when iterating over an object. `map` now always returns an array, like in other libraries. The previous object behavior has been split out into `mapValues`. ([#1157](https://github.com/caolan/async/issues/1157), [#1177](https://github.com/caolan/async/issues/1177))
|
||||
- `filter`, `reject`, `some`, `every`, `detect` and their families like `{METHOD}Series` and `{METHOD}Limit` now expect an error as the first callback argument, rather than just a simple boolean. Pass `null` as the first argument, or use `fs.access` instead of `fs.exists`. ([#118](https://github.com/caolan/async/issues/118), [#774](https://github.com/caolan/async/issues/774), [#1028](https://github.com/caolan/async/issues/1028), [#1041](https://github.com/caolan/async/issues/1041))
|
||||
- `{METHOD}` and `{METHOD}Series` are now implemented in terms of `{METHOD}Limit`. This is a major internal simplification, and is not expected to cause many problems, but it does subtly affect how functions execute internally. ([#778](https://github.com/caolan/async/issues/778), [#847](https://github.com/caolan/async/issues/847))
|
||||
- `retry`'s callback is now optional. Previously, omitting the callback would partially apply the function, meaning it could be passed directly as a task to `series` or `auto`. The partially applied "control-flow" behavior has been separated out into `retryable`. ([#1054](https://github.com/caolan/async/issues/1054), [#1058](https://github.com/caolan/async/issues/1058))
|
||||
- The test function for `whilst`, `until`, and `during` used to be passed non-error args from the iteratee function's callback, but this led to weirdness where the first call of the test function would be passed no args. We have made it so the test function is never passed extra arguments, and only the `doWhilst`, `doUntil`, and `doDuring` functions pass iteratee callback arguments to the test function ([#1217](https://github.com/caolan/async/issues/1217), [#1224](https://github.com/caolan/async/issues/1224))
|
||||
- The `q.tasks` array has been renamed `q._tasks` and is now implemented as a doubly linked list (DLL). Any code that used to interact with this array will need to be updated to either use the provided helpers or support DLLs ([#1205](https://github.com/caolan/async/issues/1205)).
|
||||
- The timing of the `q.saturated()` callback in a `queue` has been modified to better reflect when tasks pushed to the queue will start queueing. ([#724](https://github.com/caolan/async/issues/724), [#1078](https://github.com/caolan/async/issues/1078))
|
||||
- Removed `iterator` method in favour of [ES2015 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators ) which natively supports arrays ([#1237](https://github.com/caolan/async/issues/1237))
|
||||
- Dropped support for Component, Jam, SPM, and Volo ([#1175](https://github.com/caolan/async/issues/1175), #[#176](https://github.com/caolan/async/issues/176))
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Improved handling of no dependency cases in `auto` & `autoInject` ([#1147](https://github.com/caolan/async/issues/1147)).
|
||||
- Fixed a bug where the callback generated by `asyncify` with `Promises` could resolve twice ([#1197](https://github.com/caolan/async/issues/1197)).
|
||||
- Fixed several documented optional callbacks not actually being optional ([#1223](https://github.com/caolan/async/issues/1223)).
|
||||
|
||||
## Other
|
||||
|
||||
- Added `someSeries` and `everySeries` for symmetry, as well as a complete set of `any`/`anyLimit`/`anySeries` and `all`/`/allLmit`/`allSeries` aliases.
|
||||
- Added `find` as an alias for `detect. (as well as `findLimit` and `findSeries`).
|
||||
- Various doc fixes ([#1005](https://github.com/caolan/async/issues/1005), [#1008](https://github.com/caolan/async/issues/1008), [#1010](https://github.com/caolan/async/issues/1010), [#1015](https://github.com/caolan/async/issues/1015), [#1021](https://github.com/caolan/async/issues/1021), [#1037](https://github.com/caolan/async/issues/1037), [#1039](https://github.com/caolan/async/issues/1039), [#1051](https://github.com/caolan/async/issues/1051), [#1102](https://github.com/caolan/async/issues/1102), [#1107](https://github.com/caolan/async/issues/1107), [#1121](https://github.com/caolan/async/issues/1121), [#1123](https://github.com/caolan/async/issues/1123), [#1129](https://github.com/caolan/async/issues/1129), [#1135](https://github.com/caolan/async/issues/1135), [#1138](https://github.com/caolan/async/issues/1138), [#1141](https://github.com/caolan/async/issues/1141), [#1153](https://github.com/caolan/async/issues/1153), [#1216](https://github.com/caolan/async/issues/1216), [#1217](https://github.com/caolan/async/issues/1217), [#1232](https://github.com/caolan/async/issues/1232), [#1233](https://github.com/caolan/async/issues/1233), [#1236](https://github.com/caolan/async/issues/1236), [#1238](https://github.com/caolan/async/issues/1238))
|
||||
|
||||
Thank you [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac) for taking the lead on version 2 of async.
|
||||
|
||||
------------------------------------------
|
||||
|
||||
# v1.5.2
|
||||
- Allow using `"constructor"` as an argument in `memoize` ([#998](https://github.com/caolan/async/issues/998))
|
||||
- Give a better error messsage when `auto` dependency checking fails ([#994](https://github.com/caolan/async/issues/994))
|
||||
- Various doc updates ([#936](https://github.com/caolan/async/issues/936), [#956](https://github.com/caolan/async/issues/956), [#979](https://github.com/caolan/async/issues/979), [#1002](https://github.com/caolan/async/issues/1002))
|
||||
|
||||
# v1.5.1
|
||||
- Fix issue with `pause` in `queue` with concurrency enabled ([#946](https://github.com/caolan/async/issues/946))
|
||||
- `while` and `until` now pass the final result to callback ([#963](https://github.com/caolan/async/issues/963))
|
||||
- `auto` will properly handle concurrency when there is no callback ([#966](https://github.com/caolan/async/issues/966))
|
||||
- `auto` will no. properly stop execution when an error occurs ([#988](https://github.com/caolan/async/issues/988), [#993](https://github.com/caolan/async/issues/993))
|
||||
- Various doc fixes ([#971](https://github.com/caolan/async/issues/971), [#980](https://github.com/caolan/async/issues/980))
|
||||
|
||||
# v1.5.0
|
||||
|
||||
- Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) ([#892](https://github.com/caolan/async/issues/892))
|
||||
- `map` now returns an object when an object is passed in, rather than array with non-numeric keys. `map` will begin always returning an array with numeric indexes in the next major release. ([#873](https://github.com/caolan/async/issues/873))
|
||||
- `auto` now accepts an optional `concurrency` argument to limit the number o. running tasks ([#637](https://github.com/caolan/async/issues/637))
|
||||
- Added `queue#workersList()`, to retrieve the lis. of currently running tasks. ([#891](https://github.com/caolan/async/issues/891))
|
||||
- Various code simplifications ([#896](https://github.com/caolan/async/issues/896), [#904](https://github.com/caolan/async/issues/904))
|
||||
- Various doc fixes :scroll: ([#890](https://github.com/caolan/async/issues/890), [#894](https://github.com/caolan/async/issues/894), [#903](https://github.com/caolan/async/issues/903), [#905](https://github.com/caolan/async/issues/905), [#912](https://github.com/caolan/async/issues/912))
|
||||
|
||||
# v1.4.2
|
||||
|
||||
- Ensure coverage files don't get published on npm ([#879](https://github.com/caolan/async/issues/879))
|
||||
|
||||
# v1.4.1
|
||||
|
||||
- Add in overlooked `detectLimit` method ([#866](https://github.com/caolan/async/issues/866))
|
||||
- Removed unnecessary files from npm releases ([#861](https://github.com/caolan/async/issues/861))
|
||||
- Removed usage of a reserved word to prevent :boom: in older environments ([#870](https://github.com/caolan/async/issues/870))
|
||||
|
||||
# v1.4.0
|
||||
|
||||
- `asyncify` now supports promises ([#840](https://github.com/caolan/async/issues/840))
|
||||
- Added `Limit` versions of `filter` and `reject` ([#836](https://github.com/caolan/async/issues/836))
|
||||
- Add `Limit` versions of `detect`, `some` and `every` ([#828](https://github.com/caolan/async/issues/828), [#829](https://github.com/caolan/async/issues/829))
|
||||
- `some`, `every` and `detect` now short circuit early ([#828](https://github.com/caolan/async/issues/828), [#829](https://github.com/caolan/async/issues/829))
|
||||
- Improve detection of the global object ([#804](https://github.com/caolan/async/issues/804)), enabling use in WebWorkers
|
||||
- `whilst` now called with arguments from iterator ([#823](https://github.com/caolan/async/issues/823))
|
||||
- `during` now gets called with arguments from iterator ([#824](https://github.com/caolan/async/issues/824))
|
||||
- Code simplifications and optimizations aplenty ([diff](https://github.com/caolan/async/compare/v1.3.0...v1.4.0))
|
||||
|
||||
|
||||
# v1.3.0
|
||||
|
||||
New Features:
|
||||
- Added `constant`
|
||||
- Added `asyncify`/`wrapSync` for making sync functions work with callbacks. ([#671](https://github.com/caolan/async/issues/671), [#806](https://github.com/caolan/async/issues/806))
|
||||
- Added `during` and `doDuring`, which are like `whilst` with an async truth test. ([#800](https://github.com/caolan/async/issues/800))
|
||||
- `retry` now accepts an `interval` parameter to specify a delay between retries. ([#793](https://github.com/caolan/async/issues/793))
|
||||
- `async` should work better in Web Workers due to better `root` detection ([#804](https://github.com/caolan/async/issues/804))
|
||||
- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` ([#642](https://github.com/caolan/async/issues/642))
|
||||
- Various internal updates ([#786](https://github.com/caolan/async/issues/786), [#801](https://github.com/caolan/async/issues/801), [#802](https://github.com/caolan/async/issues/802), [#803](https://github.com/caolan/async/issues/803))
|
||||
- Various doc fixes ([#790](https://github.com/caolan/async/issues/790), [#794](https://github.com/caolan/async/issues/794))
|
||||
|
||||
Bug Fixes:
|
||||
- `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. ([#740](https://github.com/caolan/async/issues/740), [#744](https://github.com/caolan/async/issues/744), [#783](https://github.com/caolan/async/issues/783))
|
||||
|
||||
|
||||
# v1.2.1
|
||||
|
||||
Bug Fix:
|
||||
|
||||
- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. ([#782](https://github.com/caolan/async/issues/782))
|
||||
|
||||
|
||||
# v1.2.0
|
||||
|
||||
New Features:
|
||||
|
||||
- Added `timesLimit` ([#743](https://github.com/caolan/async/issues/743))
|
||||
- `concurrency` can be changed after initialization in `queue` by setting `q.concurrency`. The new concurrency will be reflected the next time a task is processed. ([#747](https://github.com/caolan/async/issues/747), [#772](https://github.com/caolan/async/issues/772))
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
- Fixed a regression in `each` and family with empty arrays that have additional properties. ([#775](https://github.com/caolan/async/issues/775), [#777](https://github.com/caolan/async/issues/777))
|
||||
|
||||
|
||||
# v1.1.1
|
||||
|
||||
Bug Fix:
|
||||
|
||||
- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. ([#782](https://github.com/caolan/async/issues/782))
|
||||
|
||||
|
||||
# v1.1.0
|
||||
|
||||
New Features:
|
||||
|
||||
- `cargo` now supports all of the same methods and event callbacks as `queue`.
|
||||
- Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. ([#769](https://github.com/caolan/async/issues/769))
|
||||
- Optimized `map`, `eachOf`, and `waterfall` families of functions
|
||||
- Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array ([#667](https://github.com/caolan/async/issues/667)).
|
||||
- The callback is now optional for the composed results of `compose` and `seq`. ([#618](https://github.com/caolan/async/issues/618))
|
||||
- Reduced file size by 4kb, (minified version by 1kb)
|
||||
- Added code coverage through `nyc` and `coveralls` ([#768](https://github.com/caolan/async/issues/768))
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
- `forever` will no longer stack overflow with a synchronous iterator ([#622](https://github.com/caolan/async/issues/622))
|
||||
- `eachLimit` and other limit functions will stop iterating once an error occurs ([#754](https://github.com/caolan/async/issues/754))
|
||||
- Always pass `null` in callbacks when there is no error ([#439](https://github.com/caolan/async/issues/439))
|
||||
- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue ([#668](https://github.com/caolan/async/issues/668))
|
||||
- `each` and family will properly handle an empty array ([#578](https://github.com/caolan/async/issues/578))
|
||||
- `eachSeries` and family will finish if the underlying array is modified during execution ([#557](https://github.com/caolan/async/issues/557))
|
||||
- `queue` will throw if a non-function is passed to `q.push()` ([#593](https://github.com/caolan/async/issues/593))
|
||||
- Doc fixes ([#629](https://github.com/caolan/async/issues/629), [#766](https://github.com/caolan/async/issues/766))
|
||||
|
||||
|
||||
# v1.0.0
|
||||
|
||||
No known breaking changes, we are simply complying with semver from here on out.
|
||||
|
||||
Changes:
|
||||
|
||||
- Start using a changelog!
|
||||
- Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) ([#168](https://github.com/caolan/async/issues/168) [#704](https://github.com/caolan/async/issues/704) [#321](https://github.com/caolan/async/issues/321))
|
||||
- Detect deadlocks in `auto` ([#663](https://github.com/caolan/async/issues/663))
|
||||
- Better support for require.js ([#527](https://github.com/caolan/async/issues/527))
|
||||
- Throw if queue created with concurrency `0` ([#714](https://github.com/caolan/async/issues/714))
|
||||
- Fix unneeded iteration in `queue.resume()` ([#758](https://github.com/caolan/async/issues/758))
|
||||
- Guard against timer mocking overriding `setImmediate` ([#609](https://github.com/caolan/async/issues/609) [#611](https://github.com/caolan/async/issues/611))
|
||||
- Miscellaneous doc fixes ([#542](https://github.com/caolan/async/issues/542) [#596](https://github.com/caolan/async/issues/596) [#615](https://github.com/caolan/async/issues/615) [#628](https://github.com/caolan/async/issues/628) [#631](https://github.com/caolan/async/issues/631) [#690](https://github.com/caolan/async/issues/690) [#729](https://github.com/caolan/async/issues/729))
|
||||
- Use single noop function internally ([#546](https://github.com/caolan/async/issues/546))
|
||||
- Optimize internal `_each`, `_map` and `_keys` functions.
|
||||
19
api.hyungi.net/node_modules/@pm2/io/node_modules/async/LICENSE
generated
vendored
Normal file
19
api.hyungi.net/node_modules/@pm2/io/node_modules/async/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010-2018 Caolan McMahon
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
56
api.hyungi.net/node_modules/@pm2/io/node_modules/async/README.md
generated
vendored
Normal file
56
api.hyungi.net/node_modules/@pm2/io/node_modules/async/README.md
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||

|
||||
|
||||
[](https://travis-ci.org/caolan/async)
|
||||
[](https://www.npmjs.com/package/async)
|
||||
[](https://coveralls.io/r/caolan/async?branch=master)
|
||||
[](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://www.libhive.com/providers/npm/packages/async)
|
||||
[](https://www.jsdelivr.com/package/npm/async)
|
||||
|
||||
|
||||
Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.
|
||||
|
||||
This version of the package is optimized for the Node.js environment. If you use Async with webpack, install [`async-es`](https://www.npmjs.com/package/async-es) instead.
|
||||
|
||||
For Documentation, visit <https://caolan.github.io/async/>
|
||||
|
||||
*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
|
||||
|
||||
|
||||
```javascript
|
||||
// for use with Node-style callbacks...
|
||||
var async = require("async");
|
||||
|
||||
var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
|
||||
var configs = {};
|
||||
|
||||
async.forEachOf(obj, (value, key, callback) => {
|
||||
fs.readFile(__dirname + value, "utf8", (err, data) => {
|
||||
if (err) return callback(err);
|
||||
try {
|
||||
configs[key] = JSON.parse(data);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}, err => {
|
||||
if (err) console.error(err.message);
|
||||
// configs is now a map of JSON data
|
||||
doSomethingWith(configs);
|
||||
});
|
||||
```
|
||||
|
||||
```javascript
|
||||
var async = require("async");
|
||||
|
||||
// ...or ES2017 async functions
|
||||
async.mapLimit(urls, 5, async function(url) {
|
||||
const response = await fetch(url)
|
||||
return response.body
|
||||
}, (err, results) => {
|
||||
if (err) throw err
|
||||
// results is now an array of the response bodies
|
||||
console.log(results)
|
||||
})
|
||||
```
|
||||
50
api.hyungi.net/node_modules/@pm2/io/node_modules/async/all.js
generated
vendored
Normal file
50
api.hyungi.net/node_modules/@pm2/io/node_modules/async/all.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createTester = require('./internal/createTester');
|
||||
|
||||
var _createTester2 = _interopRequireDefault(_createTester);
|
||||
|
||||
var _doParallel = require('./internal/doParallel');
|
||||
|
||||
var _doParallel2 = _interopRequireDefault(_doParallel);
|
||||
|
||||
var _notId = require('./internal/notId');
|
||||
|
||||
var _notId2 = _interopRequireDefault(_notId);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Returns `true` if every element in `coll` satisfies an async test. If any
|
||||
* iteratee call returns `false`, the main `callback` is immediately called.
|
||||
*
|
||||
* @name every
|
||||
* @static
|
||||
* @memberOf module:Collections
|
||||
* @method
|
||||
* @alias all
|
||||
* @category Collection
|
||||
* @param {Array|Iterable|Object} coll - A collection to iterate over.
|
||||
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
||||
* in the collection in parallel.
|
||||
* The iteratee must complete with a boolean result value.
|
||||
* Invoked with (item, callback).
|
||||
* @param {Function} [callback] - A callback which is called after all the
|
||||
* `iteratee` functions have finished. Result will be either `true` or `false`
|
||||
* depending on the values of the async tests. Invoked with (err, result).
|
||||
* @example
|
||||
*
|
||||
* async.every(['file1','file2','file3'], function(filePath, callback) {
|
||||
* fs.access(filePath, function(err) {
|
||||
* callback(null, !err)
|
||||
* });
|
||||
* }, function(err, result) {
|
||||
* // if result is true then every file exists
|
||||
* });
|
||||
*/
|
||||
exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
|
||||
module.exports = exports['default'];
|
||||
42
api.hyungi.net/node_modules/@pm2/io/node_modules/async/allLimit.js
generated
vendored
Normal file
42
api.hyungi.net/node_modules/@pm2/io/node_modules/async/allLimit.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createTester = require('./internal/createTester');
|
||||
|
||||
var _createTester2 = _interopRequireDefault(_createTester);
|
||||
|
||||
var _doParallelLimit = require('./internal/doParallelLimit');
|
||||
|
||||
var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
|
||||
|
||||
var _notId = require('./internal/notId');
|
||||
|
||||
var _notId2 = _interopRequireDefault(_notId);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
|
||||
*
|
||||
* @name everyLimit
|
||||
* @static
|
||||
* @memberOf module:Collections
|
||||
* @method
|
||||
* @see [async.every]{@link module:Collections.every}
|
||||
* @alias allLimit
|
||||
* @category Collection
|
||||
* @param {Array|Iterable|Object} coll - A collection to iterate over.
|
||||
* @param {number} limit - The maximum number of async operations at a time.
|
||||
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
||||
* in the collection in parallel.
|
||||
* The iteratee must complete with a boolean result value.
|
||||
* Invoked with (item, callback).
|
||||
* @param {Function} [callback] - A callback which is called after all the
|
||||
* `iteratee` functions have finished. Result will be either `true` or `false`
|
||||
* depending on the values of the async tests. Invoked with (err, result).
|
||||
*/
|
||||
exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
|
||||
module.exports = exports['default'];
|
||||
37
api.hyungi.net/node_modules/@pm2/io/node_modules/async/allSeries.js
generated
vendored
Normal file
37
api.hyungi.net/node_modules/@pm2/io/node_modules/async/allSeries.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _everyLimit = require('./everyLimit');
|
||||
|
||||
var _everyLimit2 = _interopRequireDefault(_everyLimit);
|
||||
|
||||
var _doLimit = require('./internal/doLimit');
|
||||
|
||||
var _doLimit2 = _interopRequireDefault(_doLimit);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
|
||||
*
|
||||
* @name everySeries
|
||||
* @static
|
||||
* @memberOf module:Collections
|
||||
* @method
|
||||
* @see [async.every]{@link module:Collections.every}
|
||||
* @alias allSeries
|
||||
* @category Collection
|
||||
* @param {Array|Iterable|Object} coll - A collection to iterate over.
|
||||
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
||||
* in the collection in series.
|
||||
* The iteratee must complete with a boolean result value.
|
||||
* Invoked with (item, callback).
|
||||
* @param {Function} [callback] - A callback which is called after all the
|
||||
* `iteratee` functions have finished. Result will be either `true` or `false`
|
||||
* depending on the values of the async tests. Invoked with (err, result).
|
||||
*/
|
||||
exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1);
|
||||
module.exports = exports['default'];
|
||||
52
api.hyungi.net/node_modules/@pm2/io/node_modules/async/any.js
generated
vendored
Normal file
52
api.hyungi.net/node_modules/@pm2/io/node_modules/async/any.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createTester = require('./internal/createTester');
|
||||
|
||||
var _createTester2 = _interopRequireDefault(_createTester);
|
||||
|
||||
var _doParallel = require('./internal/doParallel');
|
||||
|
||||
var _doParallel2 = _interopRequireDefault(_doParallel);
|
||||
|
||||
var _identity = require('lodash/identity');
|
||||
|
||||
var _identity2 = _interopRequireDefault(_identity);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Returns `true` if at least one element in the `coll` satisfies an async test.
|
||||
* If any iteratee call returns `true`, the main `callback` is immediately
|
||||
* called.
|
||||
*
|
||||
* @name some
|
||||
* @static
|
||||
* @memberOf module:Collections
|
||||
* @method
|
||||
* @alias any
|
||||
* @category Collection
|
||||
* @param {Array|Iterable|Object} coll - A collection to iterate over.
|
||||
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
||||
* in the collections in parallel.
|
||||
* The iteratee should complete with a boolean `result` value.
|
||||
* Invoked with (item, callback).
|
||||
* @param {Function} [callback] - A callback which is called as soon as any
|
||||
* iteratee returns `true`, or after all the iteratee functions have finished.
|
||||
* Result will be either `true` or `false` depending on the values of the async
|
||||
* tests. Invoked with (err, result).
|
||||
* @example
|
||||
*
|
||||
* async.some(['file1','file2','file3'], function(filePath, callback) {
|
||||
* fs.access(filePath, function(err) {
|
||||
* callback(null, !err)
|
||||
* });
|
||||
* }, function(err, result) {
|
||||
* // if result is true then at least one of the files exists
|
||||
* });
|
||||
*/
|
||||
exports.default = (0, _doParallel2.default)((0, _createTester2.default)(Boolean, _identity2.default));
|
||||
module.exports = exports['default'];
|
||||
43
api.hyungi.net/node_modules/@pm2/io/node_modules/async/anyLimit.js
generated
vendored
Normal file
43
api.hyungi.net/node_modules/@pm2/io/node_modules/async/anyLimit.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createTester = require('./internal/createTester');
|
||||
|
||||
var _createTester2 = _interopRequireDefault(_createTester);
|
||||
|
||||
var _doParallelLimit = require('./internal/doParallelLimit');
|
||||
|
||||
var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
|
||||
|
||||
var _identity = require('lodash/identity');
|
||||
|
||||
var _identity2 = _interopRequireDefault(_identity);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
|
||||
*
|
||||
* @name someLimit
|
||||
* @static
|
||||
* @memberOf module:Collections
|
||||
* @method
|
||||
* @see [async.some]{@link module:Collections.some}
|
||||
* @alias anyLimit
|
||||
* @category Collection
|
||||
* @param {Array|Iterable|Object} coll - A collection to iterate over.
|
||||
* @param {number} limit - The maximum number of async operations at a time.
|
||||
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
||||
* in the collections in parallel.
|
||||
* The iteratee should complete with a boolean `result` value.
|
||||
* Invoked with (item, callback).
|
||||
* @param {Function} [callback] - A callback which is called as soon as any
|
||||
* iteratee returns `true`, or after all the iteratee functions have finished.
|
||||
* Result will be either `true` or `false` depending on the values of the async
|
||||
* tests. Invoked with (err, result).
|
||||
*/
|
||||
exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(Boolean, _identity2.default));
|
||||
module.exports = exports['default'];
|
||||
38
api.hyungi.net/node_modules/@pm2/io/node_modules/async/anySeries.js
generated
vendored
Normal file
38
api.hyungi.net/node_modules/@pm2/io/node_modules/async/anySeries.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _someLimit = require('./someLimit');
|
||||
|
||||
var _someLimit2 = _interopRequireDefault(_someLimit);
|
||||
|
||||
var _doLimit = require('./internal/doLimit');
|
||||
|
||||
var _doLimit2 = _interopRequireDefault(_doLimit);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
|
||||
*
|
||||
* @name someSeries
|
||||
* @static
|
||||
* @memberOf module:Collections
|
||||
* @method
|
||||
* @see [async.some]{@link module:Collections.some}
|
||||
* @alias anySeries
|
||||
* @category Collection
|
||||
* @param {Array|Iterable|Object} coll - A collection to iterate over.
|
||||
* @param {AsyncFunction} iteratee - An async truth test to apply to each item
|
||||
* in the collections in series.
|
||||
* The iteratee should complete with a boolean `result` value.
|
||||
* Invoked with (item, callback).
|
||||
* @param {Function} [callback] - A callback which is called as soon as any
|
||||
* iteratee returns `true`, or after all the iteratee functions have finished.
|
||||
* Result will be either `true` or `false` depending on the values of the async
|
||||
* tests. Invoked with (err, result).
|
||||
*/
|
||||
exports.default = (0, _doLimit2.default)(_someLimit2.default, 1);
|
||||
module.exports = exports['default'];
|
||||
68
api.hyungi.net/node_modules/@pm2/io/node_modules/async/apply.js
generated
vendored
Normal file
68
api.hyungi.net/node_modules/@pm2/io/node_modules/async/apply.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (fn /*, ...args*/) {
|
||||
var args = (0, _slice2.default)(arguments, 1);
|
||||
return function () /*callArgs*/{
|
||||
var callArgs = (0, _slice2.default)(arguments);
|
||||
return fn.apply(null, args.concat(callArgs));
|
||||
};
|
||||
};
|
||||
|
||||
var _slice = require('./internal/slice');
|
||||
|
||||
var _slice2 = _interopRequireDefault(_slice);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Creates a continuation function with some arguments already applied.
|
||||
*
|
||||
* Useful as a shorthand when combined with other control flow functions. Any
|
||||
* arguments passed to the returned function are added to the arguments
|
||||
* originally passed to apply.
|
||||
*
|
||||
* @name apply
|
||||
* @static
|
||||
* @memberOf module:Utils
|
||||
* @method
|
||||
* @category Util
|
||||
* @param {Function} fn - The function you want to eventually apply all
|
||||
* arguments to. Invokes with (arguments...).
|
||||
* @param {...*} arguments... - Any number of arguments to automatically apply
|
||||
* when the continuation is called.
|
||||
* @returns {Function} the partially-applied function
|
||||
* @example
|
||||
*
|
||||
* // using apply
|
||||
* async.parallel([
|
||||
* async.apply(fs.writeFile, 'testfile1', 'test1'),
|
||||
* async.apply(fs.writeFile, 'testfile2', 'test2')
|
||||
* ]);
|
||||
*
|
||||
*
|
||||
* // the same process without using apply
|
||||
* async.parallel([
|
||||
* function(callback) {
|
||||
* fs.writeFile('testfile1', 'test1', callback);
|
||||
* },
|
||||
* function(callback) {
|
||||
* fs.writeFile('testfile2', 'test2', callback);
|
||||
* }
|
||||
* ]);
|
||||
*
|
||||
* // It's possible to pass any number of additional arguments when calling the
|
||||
* // continuation:
|
||||
*
|
||||
* node> var fn = async.apply(sys.puts, 'one');
|
||||
* node> fn('two', 'three');
|
||||
* one
|
||||
* two
|
||||
* three
|
||||
*/
|
||||
module.exports = exports['default'];
|
||||
51
api.hyungi.net/node_modules/@pm2/io/node_modules/async/applyEach.js
generated
vendored
Normal file
51
api.hyungi.net/node_modules/@pm2/io/node_modules/async/applyEach.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _applyEach = require('./internal/applyEach');
|
||||
|
||||
var _applyEach2 = _interopRequireDefault(_applyEach);
|
||||
|
||||
var _map = require('./map');
|
||||
|
||||
var _map2 = _interopRequireDefault(_map);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Applies the provided arguments to each function in the array, calling
|
||||
* `callback` after all functions have completed. If you only provide the first
|
||||
* argument, `fns`, then it will return a function which lets you pass in the
|
||||
* arguments as if it were a single function call. If more arguments are
|
||||
* provided, `callback` is required while `args` is still optional.
|
||||
*
|
||||
* @name applyEach
|
||||
* @static
|
||||
* @memberOf module:ControlFlow
|
||||
* @method
|
||||
* @category Control Flow
|
||||
* @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s
|
||||
* to all call with the same arguments
|
||||
* @param {...*} [args] - any number of separate arguments to pass to the
|
||||
* function.
|
||||
* @param {Function} [callback] - the final argument should be the callback,
|
||||
* called when all functions have completed processing.
|
||||
* @returns {Function} - If only the first argument, `fns`, is provided, it will
|
||||
* return a function which lets you pass in the arguments as if it were a single
|
||||
* function call. The signature is `(..args, callback)`. If invoked with any
|
||||
* arguments, `callback` is required.
|
||||
* @example
|
||||
*
|
||||
* async.applyEach([enableSearch, updateSchema], 'bucket', callback);
|
||||
*
|
||||
* // partial application example:
|
||||
* async.each(
|
||||
* buckets,
|
||||
* async.applyEach([enableSearch, updateSchema]),
|
||||
* callback
|
||||
* );
|
||||
*/
|
||||
exports.default = (0, _applyEach2.default)(_map2.default);
|
||||
module.exports = exports['default'];
|
||||
37
api.hyungi.net/node_modules/@pm2/io/node_modules/async/applyEachSeries.js
generated
vendored
Normal file
37
api.hyungi.net/node_modules/@pm2/io/node_modules/async/applyEachSeries.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _applyEach = require('./internal/applyEach');
|
||||
|
||||
var _applyEach2 = _interopRequireDefault(_applyEach);
|
||||
|
||||
var _mapSeries = require('./mapSeries');
|
||||
|
||||
var _mapSeries2 = _interopRequireDefault(_mapSeries);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
|
||||
*
|
||||
* @name applyEachSeries
|
||||
* @static
|
||||
* @memberOf module:ControlFlow
|
||||
* @method
|
||||
* @see [async.applyEach]{@link module:ControlFlow.applyEach}
|
||||
* @category Control Flow
|
||||
* @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s to all
|
||||
* call with the same arguments
|
||||
* @param {...*} [args] - any number of separate arguments to pass to the
|
||||
* function.
|
||||
* @param {Function} [callback] - the final argument should be the callback,
|
||||
* called when all functions have completed processing.
|
||||
* @returns {Function} - If only the first argument is provided, it will return
|
||||
* a function which lets you pass in the arguments as if it were a single
|
||||
* function call.
|
||||
*/
|
||||
exports.default = (0, _applyEach2.default)(_mapSeries2.default);
|
||||
module.exports = exports['default'];
|
||||
110
api.hyungi.net/node_modules/@pm2/io/node_modules/async/asyncify.js
generated
vendored
Normal file
110
api.hyungi.net/node_modules/@pm2/io/node_modules/async/asyncify.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = asyncify;
|
||||
|
||||
var _isObject = require('lodash/isObject');
|
||||
|
||||
var _isObject2 = _interopRequireDefault(_isObject);
|
||||
|
||||
var _initialParams = require('./internal/initialParams');
|
||||
|
||||
var _initialParams2 = _interopRequireDefault(_initialParams);
|
||||
|
||||
var _setImmediate = require('./internal/setImmediate');
|
||||
|
||||
var _setImmediate2 = _interopRequireDefault(_setImmediate);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Take a sync function and make it async, passing its return value to a
|
||||
* callback. This is useful for plugging sync functions into a waterfall,
|
||||
* series, or other async functions. Any arguments passed to the generated
|
||||
* function will be passed to the wrapped function (except for the final
|
||||
* callback argument). Errors thrown will be passed to the callback.
|
||||
*
|
||||
* If the function passed to `asyncify` returns a Promise, that promises's
|
||||
* resolved/rejected state will be used to call the callback, rather than simply
|
||||
* the synchronous return value.
|
||||
*
|
||||
* This also means you can asyncify ES2017 `async` functions.
|
||||
*
|
||||
* @name asyncify
|
||||
* @static
|
||||
* @memberOf module:Utils
|
||||
* @method
|
||||
* @alias wrapSync
|
||||
* @category Util
|
||||
* @param {Function} func - The synchronous function, or Promise-returning
|
||||
* function to convert to an {@link AsyncFunction}.
|
||||
* @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
|
||||
* invoked with `(args..., callback)`.
|
||||
* @example
|
||||
*
|
||||
* // passing a regular synchronous function
|
||||
* async.waterfall([
|
||||
* async.apply(fs.readFile, filename, "utf8"),
|
||||
* async.asyncify(JSON.parse),
|
||||
* function (data, next) {
|
||||
* // data is the result of parsing the text.
|
||||
* // If there was a parsing error, it would have been caught.
|
||||
* }
|
||||
* ], callback);
|
||||
*
|
||||
* // passing a function returning a promise
|
||||
* async.waterfall([
|
||||
* async.apply(fs.readFile, filename, "utf8"),
|
||||
* async.asyncify(function (contents) {
|
||||
* return db.model.create(contents);
|
||||
* }),
|
||||
* function (model, next) {
|
||||
* // `model` is the instantiated model object.
|
||||
* // If there was an error, this function would be skipped.
|
||||
* }
|
||||
* ], callback);
|
||||
*
|
||||
* // es2017 example, though `asyncify` is not needed if your JS environment
|
||||
* // supports async functions out of the box
|
||||
* var q = async.queue(async.asyncify(async function(file) {
|
||||
* var intermediateStep = await processFile(file);
|
||||
* return await somePromise(intermediateStep)
|
||||
* }));
|
||||
*
|
||||
* q.push(files);
|
||||
*/
|
||||
function asyncify(func) {
|
||||
return (0, _initialParams2.default)(function (args, callback) {
|
||||
var result;
|
||||
try {
|
||||
result = func.apply(this, args);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
// if result is Promise object
|
||||
if ((0, _isObject2.default)(result) && typeof result.then === 'function') {
|
||||
result.then(function (value) {
|
||||
invokeCallback(callback, null, value);
|
||||
}, function (err) {
|
||||
invokeCallback(callback, err.message ? err : new Error(err));
|
||||
});
|
||||
} else {
|
||||
callback(null, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function invokeCallback(callback, error, value) {
|
||||
try {
|
||||
callback(error, value);
|
||||
} catch (e) {
|
||||
(0, _setImmediate2.default)(rethrow, e);
|
||||
}
|
||||
}
|
||||
|
||||
function rethrow(error) {
|
||||
throw error;
|
||||
}
|
||||
module.exports = exports['default'];
|
||||
289
api.hyungi.net/node_modules/@pm2/io/node_modules/async/auto.js
generated
vendored
Normal file
289
api.hyungi.net/node_modules/@pm2/io/node_modules/async/auto.js
generated
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (tasks, concurrency, callback) {
|
||||
if (typeof concurrency === 'function') {
|
||||
// concurrency is optional, shift the args.
|
||||
callback = concurrency;
|
||||
concurrency = null;
|
||||
}
|
||||
callback = (0, _once2.default)(callback || _noop2.default);
|
||||
var keys = (0, _keys2.default)(tasks);
|
||||
var numTasks = keys.length;
|
||||
if (!numTasks) {
|
||||
return callback(null);
|
||||
}
|
||||
if (!concurrency) {
|
||||
concurrency = numTasks;
|
||||
}
|
||||
|
||||
var results = {};
|
||||
var runningTasks = 0;
|
||||
var hasError = false;
|
||||
|
||||
var listeners = Object.create(null);
|
||||
|
||||
var readyTasks = [];
|
||||
|
||||
// for cycle detection:
|
||||
var readyToCheck = []; // tasks that have been identified as reachable
|
||||
// without the possibility of returning to an ancestor task
|
||||
var uncheckedDependencies = {};
|
||||
|
||||
(0, _baseForOwn2.default)(tasks, function (task, key) {
|
||||
if (!(0, _isArray2.default)(task)) {
|
||||
// no dependencies
|
||||
enqueueTask(key, [task]);
|
||||
readyToCheck.push(key);
|
||||
return;
|
||||
}
|
||||
|
||||
var dependencies = task.slice(0, task.length - 1);
|
||||
var remainingDependencies = dependencies.length;
|
||||
if (remainingDependencies === 0) {
|
||||
enqueueTask(key, task);
|
||||
readyToCheck.push(key);
|
||||
return;
|
||||
}
|
||||
uncheckedDependencies[key] = remainingDependencies;
|
||||
|
||||
(0, _arrayEach2.default)(dependencies, function (dependencyName) {
|
||||
if (!tasks[dependencyName]) {
|
||||
throw new Error('async.auto task `' + key + '` has a non-existent dependency `' + dependencyName + '` in ' + dependencies.join(', '));
|
||||
}
|
||||
addListener(dependencyName, function () {
|
||||
remainingDependencies--;
|
||||
if (remainingDependencies === 0) {
|
||||
enqueueTask(key, task);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
checkForDeadlocks();
|
||||
processQueue();
|
||||
|
||||
function enqueueTask(key, task) {
|
||||
readyTasks.push(function () {
|
||||
runTask(key, task);
|
||||
});
|
||||
}
|
||||
|
||||
function processQueue() {
|
||||
if (readyTasks.length === 0 && runningTasks === 0) {
|
||||
return callback(null, results);
|
||||
}
|
||||
while (readyTasks.length && runningTasks < concurrency) {
|
||||
var run = readyTasks.shift();
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
function addListener(taskName, fn) {
|
||||
var taskListeners = listeners[taskName];
|
||||
if (!taskListeners) {
|
||||
taskListeners = listeners[taskName] = [];
|
||||
}
|
||||
|
||||
taskListeners.push(fn);
|
||||
}
|
||||
|
||||
function taskComplete(taskName) {
|
||||
var taskListeners = listeners[taskName] || [];
|
||||
(0, _arrayEach2.default)(taskListeners, function (fn) {
|
||||
fn();
|
||||
});
|
||||
processQueue();
|
||||
}
|
||||
|
||||
function runTask(key, task) {
|
||||
if (hasError) return;
|
||||
|
||||
var taskCallback = (0, _onlyOnce2.default)(function (err, result) {
|
||||
runningTasks--;
|
||||
if (arguments.length > 2) {
|
||||
result = (0, _slice2.default)(arguments, 1);
|
||||
}
|
||||
if (err) {
|
||||
var safeResults = {};
|
||||
(0, _baseForOwn2.default)(results, function (val, rkey) {
|
||||
safeResults[rkey] = val;
|
||||
});
|
||||
safeResults[key] = result;
|
||||
hasError = true;
|
||||
listeners = Object.create(null);
|
||||
|
||||
callback(err, safeResults);
|
||||
} else {
|
||||
results[key] = result;
|
||||
taskComplete(key);
|
||||
}
|
||||
});
|
||||
|
||||
runningTasks++;
|
||||
var taskFn = (0, _wrapAsync2.default)(task[task.length - 1]);
|
||||
if (task.length > 1) {
|
||||
taskFn(results, taskCallback);
|
||||
} else {
|
||||
taskFn(taskCallback);
|
||||
}
|
||||
}
|
||||
|
||||
function checkForDeadlocks() {
|
||||
// Kahn's algorithm
|
||||
// https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
|
||||
// http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
|
||||
var currentTask;
|
||||
var counter = 0;
|
||||
while (readyToCheck.length) {
|
||||
currentTask = readyToCheck.pop();
|
||||
counter++;
|
||||
(0, _arrayEach2.default)(getDependents(currentTask), function (dependent) {
|
||||
if (--uncheckedDependencies[dependent] === 0) {
|
||||
readyToCheck.push(dependent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (counter !== numTasks) {
|
||||
throw new Error('async.auto cannot execute tasks due to a recursive dependency');
|
||||
}
|
||||
}
|
||||
|
||||
function getDependents(taskName) {
|
||||
var result = [];
|
||||
(0, _baseForOwn2.default)(tasks, function (task, key) {
|
||||
if ((0, _isArray2.default)(task) && (0, _baseIndexOf2.default)(task, taskName, 0) >= 0) {
|
||||
result.push(key);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
var _arrayEach = require('lodash/_arrayEach');
|
||||
|
||||
var _arrayEach2 = _interopRequireDefault(_arrayEach);
|
||||
|
||||
var _baseForOwn = require('lodash/_baseForOwn');
|
||||
|
||||
var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
|
||||
|
||||
var _baseIndexOf = require('lodash/_baseIndexOf');
|
||||
|
||||
var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
|
||||
|
||||
var _isArray = require('lodash/isArray');
|
||||
|
||||
var _isArray2 = _interopRequireDefault(_isArray);
|
||||
|
||||
var _keys = require('lodash/keys');
|
||||
|
||||
var _keys2 = _interopRequireDefault(_keys);
|
||||
|
||||
var _noop = require('lodash/noop');
|
||||
|
||||
var _noop2 = _interopRequireDefault(_noop);
|
||||
|
||||
var _slice = require('./internal/slice');
|
||||
|
||||
var _slice2 = _interopRequireDefault(_slice);
|
||||
|
||||
var _once = require('./internal/once');
|
||||
|
||||
var _once2 = _interopRequireDefault(_once);
|
||||
|
||||
var _onlyOnce = require('./internal/onlyOnce');
|
||||
|
||||
var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
|
||||
|
||||
var _wrapAsync = require('./internal/wrapAsync');
|
||||
|
||||
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
module.exports = exports['default'];
|
||||
|
||||
/**
|
||||
* Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
|
||||
* their requirements. Each function can optionally depend on other functions
|
||||
* being completed first, and each function is run as soon as its requirements
|
||||
* are satisfied.
|
||||
*
|
||||
* If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
|
||||
* will stop. Further tasks will not execute (so any other functions depending
|
||||
* on it will not run), and the main `callback` is immediately called with the
|
||||
* error.
|
||||
*
|
||||
* {@link AsyncFunction}s also receive an object containing the results of functions which
|
||||
* have completed so far as the first argument, if they have dependencies. If a
|
||||
* task function has no dependencies, it will only be passed a callback.
|
||||
*
|
||||
* @name auto
|
||||
* @static
|
||||
* @memberOf module:ControlFlow
|
||||
* @method
|
||||
* @category Control Flow
|
||||
* @param {Object} tasks - An object. Each of its properties is either a
|
||||
* function or an array of requirements, with the {@link AsyncFunction} itself the last item
|
||||
* in the array. The object's key of a property serves as the name of the task
|
||||
* defined by that property, i.e. can be used when specifying requirements for
|
||||
* other tasks. The function receives one or two arguments:
|
||||
* * a `results` object, containing the results of the previously executed
|
||||
* functions, only passed if the task has any dependencies,
|
||||
* * a `callback(err, result)` function, which must be called when finished,
|
||||
* passing an `error` (which can be `null`) and the result of the function's
|
||||
* execution.
|
||||
* @param {number} [concurrency=Infinity] - An optional `integer` for
|
||||
* determining the maximum number of tasks that can be run in parallel. By
|
||||
* default, as many as possible.
|
||||
* @param {Function} [callback] - An optional callback which is called when all
|
||||
* the tasks have been completed. It receives the `err` argument if any `tasks`
|
||||
* pass an error to their callback. Results are always returned; however, if an
|
||||
* error occurs, no further `tasks` will be performed, and the results object
|
||||
* will only contain partial results. Invoked with (err, results).
|
||||
* @returns undefined
|
||||
* @example
|
||||
*
|
||||
* async.auto({
|
||||
* // this function will just be passed a callback
|
||||
* readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
|
||||
* showData: ['readData', function(results, cb) {
|
||||
* // results.readData is the file's contents
|
||||
* // ...
|
||||
* }]
|
||||
* }, callback);
|
||||
*
|
||||
* async.auto({
|
||||
* get_data: function(callback) {
|
||||
* console.log('in get_data');
|
||||
* // async code to get some data
|
||||
* callback(null, 'data', 'converted to array');
|
||||
* },
|
||||
* make_folder: function(callback) {
|
||||
* console.log('in make_folder');
|
||||
* // async code to create a directory to store a file in
|
||||
* // this is run at the same time as getting the data
|
||||
* callback(null, 'folder');
|
||||
* },
|
||||
* write_file: ['get_data', 'make_folder', function(results, callback) {
|
||||
* console.log('in write_file', JSON.stringify(results));
|
||||
* // once there is some data and the directory exists,
|
||||
* // write the data to a file in the directory
|
||||
* callback(null, 'filename');
|
||||
* }],
|
||||
* email_link: ['write_file', function(results, callback) {
|
||||
* console.log('in email_link', JSON.stringify(results));
|
||||
* // once the file is written let's email a link to it...
|
||||
* // results.write_file contains the filename returned by write_file.
|
||||
* callback(null, {'file':results.write_file, 'email':'user@example.com'});
|
||||
* }]
|
||||
* }, function(err, results) {
|
||||
* console.log('err = ', err);
|
||||
* console.log('results = ', results);
|
||||
* });
|
||||
*/
|
||||
170
api.hyungi.net/node_modules/@pm2/io/node_modules/async/autoInject.js
generated
vendored
Normal file
170
api.hyungi.net/node_modules/@pm2/io/node_modules/async/autoInject.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = autoInject;
|
||||
|
||||
var _auto = require('./auto');
|
||||
|
||||
var _auto2 = _interopRequireDefault(_auto);
|
||||
|
||||
var _baseForOwn = require('lodash/_baseForOwn');
|
||||
|
||||
var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
|
||||
|
||||
var _arrayMap = require('lodash/_arrayMap');
|
||||
|
||||
var _arrayMap2 = _interopRequireDefault(_arrayMap);
|
||||
|
||||
var _isArray = require('lodash/isArray');
|
||||
|
||||
var _isArray2 = _interopRequireDefault(_isArray);
|
||||
|
||||
var _trim = require('lodash/trim');
|
||||
|
||||
var _trim2 = _interopRequireDefault(_trim);
|
||||
|
||||
var _wrapAsync = require('./internal/wrapAsync');
|
||||
|
||||
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
|
||||
var FN_ARG_SPLIT = /,/;
|
||||
var FN_ARG = /(=.+)?(\s*)$/;
|
||||
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
|
||||
|
||||
function parseParams(func) {
|
||||
func = func.toString().replace(STRIP_COMMENTS, '');
|
||||
func = func.match(FN_ARGS)[2].replace(' ', '');
|
||||
func = func ? func.split(FN_ARG_SPLIT) : [];
|
||||
func = func.map(function (arg) {
|
||||
return (0, _trim2.default)(arg.replace(FN_ARG, ''));
|
||||
});
|
||||
return func;
|
||||
}
|
||||
|
||||
/**
|
||||
* A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
|
||||
* tasks are specified as parameters to the function, after the usual callback
|
||||
* parameter, with the parameter names matching the names of the tasks it
|
||||
* depends on. This can provide even more readable task graphs which can be
|
||||
* easier to maintain.
|
||||
*
|
||||
* If a final callback is specified, the task results are similarly injected,
|
||||
* specified as named parameters after the initial error parameter.
|
||||
*
|
||||
* The autoInject function is purely syntactic sugar and its semantics are
|
||||
* otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
|
||||
*
|
||||
* @name autoInject
|
||||
* @static
|
||||
* @memberOf module:ControlFlow
|
||||
* @method
|
||||
* @see [async.auto]{@link module:ControlFlow.auto}
|
||||
* @category Control Flow
|
||||
* @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
|
||||
* the form 'func([dependencies...], callback). The object's key of a property
|
||||
* serves as the name of the task defined by that property, i.e. can be used
|
||||
* when specifying requirements for other tasks.
|
||||
* * The `callback` parameter is a `callback(err, result)` which must be called
|
||||
* when finished, passing an `error` (which can be `null`) and the result of
|
||||
* the function's execution. The remaining parameters name other tasks on
|
||||
* which the task is dependent, and the results from those tasks are the
|
||||
* arguments of those parameters.
|
||||
* @param {Function} [callback] - An optional callback which is called when all
|
||||
* the tasks have been completed. It receives the `err` argument if any `tasks`
|
||||
* pass an error to their callback, and a `results` object with any completed
|
||||
* task results, similar to `auto`.
|
||||
* @example
|
||||
*
|
||||
* // The example from `auto` can be rewritten as follows:
|
||||
* async.autoInject({
|
||||
* get_data: function(callback) {
|
||||
* // async code to get some data
|
||||
* callback(null, 'data', 'converted to array');
|
||||
* },
|
||||
* make_folder: function(callback) {
|
||||
* // async code to create a directory to store a file in
|
||||
* // this is run at the same time as getting the data
|
||||
* callback(null, 'folder');
|
||||
* },
|
||||
* write_file: function(get_data, make_folder, callback) {
|
||||
* // once there is some data and the directory exists,
|
||||
* // write the data to a file in the directory
|
||||
* callback(null, 'filename');
|
||||
* },
|
||||
* email_link: function(write_file, callback) {
|
||||
* // once the file is written let's email a link to it...
|
||||
* // write_file contains the filename returned by write_file.
|
||||
* callback(null, {'file':write_file, 'email':'user@example.com'});
|
||||
* }
|
||||
* }, function(err, results) {
|
||||
* console.log('err = ', err);
|
||||
* console.log('email_link = ', results.email_link);
|
||||
* });
|
||||
*
|
||||
* // If you are using a JS minifier that mangles parameter names, `autoInject`
|
||||
* // will not work with plain functions, since the parameter names will be
|
||||
* // collapsed to a single letter identifier. To work around this, you can
|
||||
* // explicitly specify the names of the parameters your task function needs
|
||||
* // in an array, similar to Angular.js dependency injection.
|
||||
*
|
||||
* // This still has an advantage over plain `auto`, since the results a task
|
||||
* // depends on are still spread into arguments.
|
||||
* async.autoInject({
|
||||
* //...
|
||||
* write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
|
||||
* callback(null, 'filename');
|
||||
* }],
|
||||
* email_link: ['write_file', function(write_file, callback) {
|
||||
* callback(null, {'file':write_file, 'email':'user@example.com'});
|
||||
* }]
|
||||
* //...
|
||||
* }, function(err, results) {
|
||||
* console.log('err = ', err);
|
||||
* console.log('email_link = ', results.email_link);
|
||||
* });
|
||||
*/
|
||||
function autoInject(tasks, callback) {
|
||||
var newTasks = {};
|
||||
|
||||
(0, _baseForOwn2.default)(tasks, function (taskFn, key) {
|
||||
var params;
|
||||
var fnIsAsync = (0, _wrapAsync.isAsync)(taskFn);
|
||||
var hasNoDeps = !fnIsAsync && taskFn.length === 1 || fnIsAsync && taskFn.length === 0;
|
||||
|
||||
if ((0, _isArray2.default)(taskFn)) {
|
||||
params = taskFn.slice(0, -1);
|
||||
taskFn = taskFn[taskFn.length - 1];
|
||||
|
||||
newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
|
||||
} else if (hasNoDeps) {
|
||||
// no dependencies, use the function as-is
|
||||
newTasks[key] = taskFn;
|
||||
} else {
|
||||
params = parseParams(taskFn);
|
||||
if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
|
||||
throw new Error("autoInject task functions require explicit parameters.");
|
||||
}
|
||||
|
||||
// remove callback param
|
||||
if (!fnIsAsync) params.pop();
|
||||
|
||||
newTasks[key] = params.concat(newTask);
|
||||
}
|
||||
|
||||
function newTask(results, taskCb) {
|
||||
var newArgs = (0, _arrayMap2.default)(params, function (name) {
|
||||
return results[name];
|
||||
});
|
||||
newArgs.push(taskCb);
|
||||
(0, _wrapAsync2.default)(taskFn).apply(null, newArgs);
|
||||
}
|
||||
});
|
||||
|
||||
(0, _auto2.default)(newTasks, callback);
|
||||
}
|
||||
module.exports = exports['default'];
|
||||
17
api.hyungi.net/node_modules/@pm2/io/node_modules/async/bower.json
generated
vendored
Normal file
17
api.hyungi.net/node_modules/@pm2/io/node_modules/async/bower.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "async",
|
||||
"main": "dist/async.js",
|
||||
"ignore": [
|
||||
"bower_components",
|
||||
"lib",
|
||||
"mocha_test",
|
||||
"node_modules",
|
||||
"perf",
|
||||
"support",
|
||||
"**/.*",
|
||||
"*.config.js",
|
||||
"*.json",
|
||||
"index.js",
|
||||
"Makefile"
|
||||
]
|
||||
}
|
||||
94
api.hyungi.net/node_modules/@pm2/io/node_modules/async/cargo.js
generated
vendored
Normal file
94
api.hyungi.net/node_modules/@pm2/io/node_modules/async/cargo.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = cargo;
|
||||
|
||||
var _queue = require('./internal/queue');
|
||||
|
||||
var _queue2 = _interopRequireDefault(_queue);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* A cargo of tasks for the worker function to complete. Cargo inherits all of
|
||||
* the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
|
||||
* @typedef {Object} CargoObject
|
||||
* @memberOf module:ControlFlow
|
||||
* @property {Function} length - A function returning the number of items
|
||||
* waiting to be processed. Invoke like `cargo.length()`.
|
||||
* @property {number} payload - An `integer` for determining how many tasks
|
||||
* should be process per round. This property can be changed after a `cargo` is
|
||||
* created to alter the payload on-the-fly.
|
||||
* @property {Function} push - Adds `task` to the `queue`. The callback is
|
||||
* called once the `worker` has finished processing the task. Instead of a
|
||||
* single task, an array of `tasks` can be submitted. The respective callback is
|
||||
* used for every task in the list. Invoke like `cargo.push(task, [callback])`.
|
||||
* @property {Function} saturated - A callback that is called when the
|
||||
* `queue.length()` hits the concurrency and further tasks will be queued.
|
||||
* @property {Function} empty - A callback that is called when the last item
|
||||
* from the `queue` is given to a `worker`.
|
||||
* @property {Function} drain - A callback that is called when the last item
|
||||
* from the `queue` has returned from the `worker`.
|
||||
* @property {Function} idle - a function returning false if there are items
|
||||
* waiting or being processed, or true if not. Invoke like `cargo.idle()`.
|
||||
* @property {Function} pause - a function that pauses the processing of tasks
|
||||
* until `resume()` is called. Invoke like `cargo.pause()`.
|
||||
* @property {Function} resume - a function that resumes the processing of
|
||||
* queued tasks when the queue is paused. Invoke like `cargo.resume()`.
|
||||
* @property {Function} kill - a function that removes the `drain` callback and
|
||||
* empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a `cargo` object with the specified payload. Tasks added to the
|
||||
* cargo will be processed altogether (up to the `payload` limit). If the
|
||||
* `worker` is in progress, the task is queued until it becomes available. Once
|
||||
* the `worker` has completed some tasks, each callback of those tasks is
|
||||
* called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
|
||||
* for how `cargo` and `queue` work.
|
||||
*
|
||||
* While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
|
||||
* at a time, cargo passes an array of tasks to a single worker, repeating
|
||||
* when the worker is finished.
|
||||
*
|
||||
* @name cargo
|
||||
* @static
|
||||
* @memberOf module:ControlFlow
|
||||
* @method
|
||||
* @see [async.queue]{@link module:ControlFlow.queue}
|
||||
* @category Control Flow
|
||||
* @param {AsyncFunction} worker - An asynchronous function for processing an array
|
||||
* of queued tasks. Invoked with `(tasks, callback)`.
|
||||
* @param {number} [payload=Infinity] - An optional `integer` for determining
|
||||
* how many tasks should be processed per round; if omitted, the default is
|
||||
* unlimited.
|
||||
* @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
|
||||
* attached as certain properties to listen for specific events during the
|
||||
* lifecycle of the cargo and inner queue.
|
||||
* @example
|
||||
*
|
||||
* // create a cargo object with payload 2
|
||||
* var cargo = async.cargo(function(tasks, callback) {
|
||||
* for (var i=0; i<tasks.length; i++) {
|
||||
* console.log('hello ' + tasks[i].name);
|
||||
* }
|
||||
* callback();
|
||||
* }, 2);
|
||||
*
|
||||
* // add some items
|
||||
* cargo.push({name: 'foo'}, function(err) {
|
||||
* console.log('finished processing foo');
|
||||
* });
|
||||
* cargo.push({name: 'bar'}, function(err) {
|
||||
* console.log('finished processing bar');
|
||||
* });
|
||||
* cargo.push({name: 'baz'}, function(err) {
|
||||
* console.log('finished processing baz');
|
||||
* });
|
||||
*/
|
||||
function cargo(worker, payload) {
|
||||
return (0, _queue2.default)(worker, 1, payload);
|
||||
}
|
||||
module.exports = exports['default'];
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user