wait-on is a cross-platform command line utility & Node.js API which will wait for files, ports, sockets, & http(s) resources khổng lồ become available
This commit does not belong khổng lồ any branch on this repository, và may belong to a fork outside of the repository.
Bạn đang xem: Wait on definition & meaning

wait-on will wait for period of time for a file to stop growing before triggering availability which is good for monitoring files that are being built. Likewise wait-on will wait for period of time for other resources to remain available before triggering success.
For http(s) resources wait-on will check that the requests are returning 2XX (success) lớn HEAD or GET requests (after following any redirects).
wait-on can also be used in reverse mode which waits for resources to NOT be available. This is useful in waiting for services to lớn shutdown before continuing. (Thanks
skarbovskiy for adding this feature)

InstallationLatest version 4+ requires Node.js 10+
(Node.js v8 users can use wait-on
npm install wait-on # local versionORnpm install -g wait-on # global version
Usage
Use from command line or using Node.js programmatic API.CLI UsageAssuming NEXT_CMD is the command to run when resources are available, then wait-on will wait & then exit with a successful exit code (0) once all resources are available, causing NEXT_CMD to be run.
wait-on can also be used in reverse mode, which waits for resources lớn NOT be available. This is useful in waiting for services khổng lồ shutdown before continuing. (Thanks
skarbovskiy for adding)
If wait-on is interrupted before all resources are available, it will exit with a non-zero exit code and thus NEXT_CMD will not be run.
Node.js API usage
= 200 && status var waitOn = require("wait-on");var opts = resources: < "file1", "http://foo.com:8000/bar", "https://my.com/cat", "http-get://foo.com:8000/bar", "https-get://my.com/cat", "tcp:foo.com:8000", "socket:/my/sock", "http://unix:/my/sock:/my/url", "http-get://unix:/my/sock:/my/url" >, delay: 1000, // initial delay in ms, mặc định 0 interval: 100, // poll interval in ms, default 250ms simultaneous: 1, // limit khổng lồ 1 connection per resource at a time timeout: 30000, // timeout in ms, mặc định Infinity tcpTimeout: 1000, // tcp timeout in ms, mặc định 300ms window: 1000, // stabilization time in ms, mặc định 750ms // http options ca: < /* strings or binaries */ >, cert: < /* strings or binaries */ >, key: < /* strings or binaries */ >, passphrase: "yourpassphrase", proxy: false /* OR proxy config as defined in axios. If not mix axios detects proxy from env vars http_proxy & https_proxy https://aryannations88.com/axios/axios#config-defaults host: "127.0.0.1", port: 9000, auth: username: "mikeymike", password: "rapunz3l" */, auth: user: "theuser", // or username pass: "thepassword" // or password , strictSSL: false, followRedirect: true, headers: "x-custom": "headers" , validateStatus: function (status) return status >= 200 && status 300; // mặc định if not provided ;// Usage with callback functionwaitOn(opts, function (err) if (err) return handleError(err); // once here, all resources are available);// Usage with promiseswaitOn(opts) .then(function () // once here, all resources are available ) .catch(function (err) handleError(err); );// Usage with async awaittry await waitOn(opts); // once here, all resources are available catch (err) handleError(err);
waitOn(opts,
opts.resources - array of string resources to wait for. Prefix determines the type of resource with the mặc định type of file:
opts.delay - optional initial delay in ms, default 0
opts.interval - optional poll resource interval in ms, mặc định 250ms
opts.log - optional flag which outputs to stdout, remaining resources waited on và when complete or errored
opts.resources - optional array of string resources lớn wait for if none are specified via command line
opts.reverse - optional flag khổng lồ reverse operation so checks are for resources being NOT available, mặc định false
opts.simultaneous - optional count to limit concurrent connections per resource at a time, setting khổng lồ 1 waits for previous connection lớn succeed, fail, or timeout before sending another, mặc định infinity
opts.timeout - optional timeout in ms, mặc định Infinity. Aborts with error.
Xem thêm: Cấu Trúc Và Cách Dùng Từ Kick Là Gì Trong Tiếng Anh? Cấu Trúc Và Cách Dùng Từ Kick Trong Câu Tiếng Anh
opts.tcpTimeout - optional tcp timeout in ms, default 300ms
opts.verbose - optional flag which outputs debug output, default false
opts.window - optional stabilization time in ms, default 750ms. Waits this amount of time for file sizes to lớn stabilize or other resource availability lớn remain unchanged.
http(s) specific options, see https://nodejs.org/api/tls.html#tls_tls_connect_options_callback for specific details
opts.ca: < /* strings or binaries */ >,opts.cert: < /* strings or binaries */ >,opts.key: < /* strings or binaries */ >,opts.passphrase: "yourpassphrase", // example proxy object host: "127.0.0.1", port: 9000, auth: username: "mikeymike", password: "rapunz3l"