CLI
Pipy can start Pipy scripts from local file system or read from remote HTTP server. Starting from Pipy version 0.10.0-1, it can read and execute scripts and configurations from Pipy Repo.
Command line arguments
$ pipy -hUsage: pipy [options] [<filename or URL>]Options:-h, -help, --help Show help information-v, -version, --version Show version information--log-level=<debug|info|warn|error> Set the level of log output--verify Verify configuration only--reuse-port Enable kernel load balancing for all listening ports--admin-port=<port> Enable administration service on the specified port--admin-tls-cert=<filename> Administration service certificate--admin-tls-key=<filename> Administration service private key--admin-tls-trusted=<filename> Client certificate(s) trusted by administration service--tls-cert=<filename> Client certificate in communication to administration service--tls-key=<filename> Client private key in communication to administration service--tls-trusted=<filename> Administration service certificate(s) trusted by client
--log-level
Setting log level to any of : debug、info、warn、error.
For example to configure the log level to debug:
pipy --log-level=debug main.js
--verify
Verify the correctness of the proxy script file.
pipy().listen(8080).serveHttP(msg => new Message(msg.body))
For example, above script has a typo in serverHTTP filter and written as serveHttP:
pipy --verify main.js2022-02-16 13:07:58.523 [ERR] [pjs] Line 4: .serveHttP(2022-02-16 13:07:58.524 [ERR] [pjs] ^2022-02-16 13:07:58.524 [ERR] [pjs] Error: not a function2022-02-16 13:07:58.524 [ERR] [pjs] Backtrace:2022-02-16 13:07:58.524 [ERR] In (root) at line 4 column 132022-02-16 13:07:58.524 [INF] [shutdown] Shutting down...2022-02-16 13:07:58.524 [INF] Stopped.Done.
--reuse-port
Enable kernel-level load balancing for all listening ports, refer to socket option SO_REUSEPORT.
--admin-port
Configures pipy built-in Admin Web Console port. If you don't provide this command line option then default port which pipy admin console listens on is 6060.
$ pipy --admin-port=60802022-02-16 13:11:31.141 [INF] [admin] Starting admin service...2022-02-16 13:11:31.141 [INF] [listener] Listening on port 6080 at ::$ pipy2022-02-16 13:11:53.533 [INF] [admin] Starting admin service...2022-02-16 13:11:53.534 [INF] [listener] Listening on port 6060 at ::
Process signals
Pipy process can receive and handle 3 kind of signals: SIGTSTP、SIGHUP、SIGINT.
$ kill -SIGNAL PID
SIGTSTP
The Pipy process dumps the current process state on receiving SIGTSTP signal.
2022-02-16 14:11:53.533 [info] Received SIGTSTP, dumping...CLASS #INSTANCES--------------------------------------------------------------------Object 2pipy::Configuration 1pipy::Console 1pipy::Data 1pipy::Global 1pipy::Hessian 1pipy::Inbound 1pipy::JSON 1pipy::OS 1pipy::Pipy 1pipy::Pipy::Script 1pipy::Pipy::Store 1pipy::XML 1pipy::algo::Algo 1pipy::crypto::Crypto 1pipy::http::Http 1pjs::Constructor<pipy::Data> 1pjs::Constructor<pipy::Message> 1pjs::Constructor<pipy::MessageEnd> 1pjs::Constructor<pipy::MessageStart> 1pjs::Constructor<pipy::Netmask> 1pjs::Constructor<pipy::Session> 1pjs::Constructor<pipy::SessionEnd> 1pjs::Constructor<pipy::URL> 1pjs::Constructor<pipy::XML::Node> 1pjs::Constructor<pipy::algo::Cache> 1pjs::Constructor<pipy::algo::HashingLoadBalancer> 1pjs::Constructor<pipy::algo::LeastWorkLoadBalancer> 1pjs::Constructor<pipy::algo::Percentile> 1pjs::Constructor<pipy::algo::ResourcePool> 1pjs::Constructor<pipy::algo::RoundRobinLoadBalancer> 1pjs::Constructor<pipy::algo::URLRouter> 1pjs::Constructor<pipy::crypto::Certificate> 1pjs::Constructor<pipy::crypto::Cipher> 1pjs::Constructor<pipy::crypto::Decipher> 1pjs::Constructor<pipy::crypto::Hash> 1pjs::Constructor<pipy::crypto::Hmac> 1pjs::Constructor<pipy::crypto::JWK> 1pjs::Constructor<pipy::crypto::JWT> 1pjs::Constructor<pipy::crypto::PrivateKey> 1pjs::Constructor<pipy::crypto::PublicKey> 1pjs::Constructor<pipy::crypto::Sign> 1pjs::Constructor<pipy::crypto::Verify> 1pjs::Constructor<pipy::http::File> 1pjs::Constructor<pjs::Array> 1pjs::Constructor<pjs::Boolean> 1pjs::Constructor<pjs::Date> 1pjs::Constructor<pjs::Number> 1pjs::Constructor<pjs::Object> 1pjs::Constructor<pjs::RegExp> 1pjs::Constructor<pjs::String> 1pjs::Function 1TOTAL 53DATA CURRENT(KB) PEAK(KB)-----------------------------------------Codebase Service 0 0Cipher 0 0Decipher 0 0Hmac 0 0Hash 0 0Sign 0 0Verify 0 0http.File 0 0Codebase 4 4Codebase Store 0 0Unknown 0 0Script 0 0HTTP Encoder 0 0TLS 0 0Message 0 0TOTAL 4 n/aPIPELINE #ALLOCATED #ACTIVE-------------------------------------------/main.js [:::8080] 0 0TOTAL 0 0INBOUND #CONNECTIONS BUFFERED(KB)-------------------------------------8080 0/0 0TOTAL 0 0OUTBOUND #CONNECTIONS BUFFERED(KB) #OVERFLOWED MAX_CONN_TIME AVG_CONN_TIME---------------------------------------------------------------------------------
SIGHUP
Pipy process reloads the codebase when it receives the SIGHUP signal.
$ pipy main.js2022-02-16 13:19:51.301 [INF] [config]2022-02-16 13:19:51.302 [INF] [config] Module /main.js2022-02-16 13:19:51.302 [INF] [config] ===============2022-02-16 13:19:51.302 [INF] [config]2022-02-16 13:19:51.302 [INF] [config] [Listen on 8080 at 0.0.0.0]2022-02-16 13:19:51.302 [INF] [config] ----->|2022-02-16 13:19:51.302 [INF] [config] |2022-02-16 13:19:51.302 [INF] [config] serveHTTP2022-02-16 13:19:51.302 [INF] [config] |2022-02-16 13:19:51.302 [INF] [config] <-----|2022-02-16 13:19:51.302 [INF] [config]2022-02-16 13:19:51.302 [INF] [listener] Listening on port 8080 at 0.0.0.02022-02-16 13:20:39.102 [INF] [restart] Reloading codebase...2022-02-16 13:20:39.102 [INF] [config]2022-02-16 13:20:39.102 [INF] [config] Module /main.js2022-02-16 13:20:39.102 [INF] [config] ===============2022-02-16 13:20:39.102 [INF] [config]2022-02-16 13:20:39.102 [INF] [config] [Listen on 8080 at 0.0.0.0]2022-02-16 13:20:39.102 [INF] [config] ----->|2022-02-16 13:20:39.102 [INF] [config] |2022-02-16 13:20:39.102 [INF] [config] serveHTTP2022-02-16 13:20:39.102 [INF] [config] |2022-02-16 13:20:39.102 [INF] [config] <-----|2022-02-16 13:20:39.102 [INF] [config]2022-02-16 13:20:39.102 [INF] [restart] Codebase reloaded
SIGINT
Pipy process can be terminated by sending SIGINT signal invoked via pressing CTRL + C keys combination on your keyboard. Upon receiving SIGINT signal, Pipy process will enter into terminating mode and no new connection requests will be entertained. If there are incomplete or in-progress pipelines, Pipy will wait for them to get completed. You can force exit by re-sending CTRL+C keys combination to Pipy process.