Products

English

English

  • Pipy Documentation
  • Introduction
    • Overview
    • Concepts
  • Getting Started
    • Build and Install
    • Quick Start
    • Getting help
  • Release
    • Release History
      • 0.10.0-1
      • 0.22.0-31
      • 0.30.0
      • 0.50.0
  • Tutorial
    • Part 1: Hello
    • Part 2: Echo
    • Part 3: Proxy
    • Part 4: Routing
    • Part 5: Loading Balancing
    • Part 6: Configuration
    • Part 7: Plugins
  • Operating
    • Admin GUI
    • CLI
    • Pipy Repo
      • Introduction
      • Quick Start
      • Demo
      • REST API
    • Statistics
  • Reference
    • API
      • Configuration
        • acceptHTTPTunnel()
        • acceptProxyProtocol()
        • acceptSOCKS()
        • acceptTLS()
        • admin()
        • branch()
        • branchMessage()
        • branchMessageStart()
        • chain()
        • compress()
        • compressHTTP()
        • connect()
        • connectHTTPTunnel()
        • connectProxyProtocol()
        • connectSOCKS()
        • connectTLS()
        • decodeBGP()
        • decodeDubbo()
        • decodeHTTPRequest()
        • decodeHTTPResponse()
        • decodeMQTT()
        • decodeMultipart()
        • decodeRESP()
        • decodeThrift()
        • decodeWebSocket()
        • decompress()
        • decompressHTTP()
        • deframe()
        • demux()
        • demuxHTTP()
        • detectProtocol()
        • dummy()
        • dump()
        • encodeBGP()
        • encodeDubbo()
        • encodeHTTPRequest()
        • encodeHTTPResponse()
        • encodeMQTT()
        • encodeRESP()
        • encodeThrift()
        • encodeWebSocket()
        • exec()
        • exit()
        • export()
        • fork()
        • handleData()
        • handleMessage()
        • handleMessageBody()
        • handleMessageEnd()
        • handleMessageStart()
        • handleStreamEnd()
        • handleStreamStart()
        • handleTLSClientHello()
        • import()
        • insert()
        • link()
        • listen()
        • loop()
        • mux()
        • muxHTTP()
        • onEnd()
        • onStart()
        • pack()
        • pipeline()
        • print()
        • read()
        • repeat()
        • replaceData()
        • replaceMessage()
        • replaceMessageBody()
        • replaceMessageEnd()
        • replaceMessageStart()
        • replaceStreamEnd()
        • replaceStreamStart()
        • replay()
        • serveHTTP()
        • split()
        • task()
        • tee()
        • throttleConcurrency()
        • throttleDataRate()
        • throttleMessageRate()
        • to()
        • use()
        • wait()
        • watch()
      • Data
        • from()
        • Data()
        • push()
        • shift()
        • shiftTo()
        • shiftWhile()
        • size
        • toArray()
      • Hessian
        • decode()
        • encode()
      • JSON
        • decode()
        • encode()
        • parse()
        • stringify()
      • Message
        • body
        • head
        • Message()
        • tail
      • MessageEnd
        • MessageEnd()
        • payload
        • tail
      • MessageStart
        • head
        • MessageStart()
      • Netmask
        • base
        • bitmask
        • broadcast
        • contains()
        • decompose()
        • first
        • hostmask
        • ip
        • last
        • mask
        • Netmask()
        • next()
        • size
        • version
      • StreamEnd
        • error
        • StreamEnd()
      • URL
        • auth
        • hash
        • host
        • hostname
        • href
        • URL()
        • origin
        • password
        • path
        • pathname
        • port
        • protocol
        • query
        • search
        • searchParams
        • username
      • URLSearchParams
        • get()
        • getAll()
        • URLSearchParams()
        • set()
        • toObject()
      • XML
        • Node
          • attributes
          • children
          • name
          • Node()
        • decode()
        • encode()
        • parse()
        • stringify()
      • algo
        • Cache
          • clear()
          • get()
          • Cache()
          • remove()
          • set()
        • HashingLoadBalancer
          • add()
          • HashingLoadBalancer()
          • next()
        • LeastWorkLoadBalancer
          • LeastWorkLoadBalancer()
          • next()
          • set()
        • LoadBalancer
          • allocate()
          • LoadBalancer()
          • provision()
          • schedule()
        • LoadBalancerResource
          • free()
          • target
        • Quota
          • consume()
          • current
          • initial
          • Quota()
          • produce()
          • reset()
        • RoundRobinLoadBalancer
          • RoundRobinLoadBalancer()
          • next()
          • set()
        • URLRouter
          • add()
          • find()
          • URLRouter()
        • hash()
        • uuid()
      • console
        • debug()
        • error()
        • info()
        • log()
        • warn()
      • crypto
        • Certificate
          • issuer
          • Certificate()
          • subject
          • subjectAltNames
        • CertificateChain
          • CertificateChain()
        • Cipher
          • final()
          • Cipher()
          • update()
        • Decipher
          • final()
          • Decipher()
          • update()
        • Hash
          • digest()
          • Hash()
          • update()
        • Hmac
          • digest()
          • Hmac()
          • update()
        • JWK
          • isValid
          • JWK()
        • JWT
          • header
          • isValid
          • JWT()
          • payload
          • verify()
        • PrivateKey
          • PrivateKey()
        • PublicKey
          • PublicKey()
        • Sign
          • Sign()
          • sign()
          • update()
        • Verify
          • Verify()
          • update()
          • verify()
      • http
        • Agent
          • new()
          • request()
        • Directory
          • new()
          • serve()
      • logging
        • BinaryLogger
          • log()
          • BinaryLogger()
          • toFile()
          • toHTTP()
          • toStderr()
          • toStdout()
          • toSyslog()
        • JSONLogger
          • log()
          • JSONLogger()
          • toFile()
          • toHTTP()
          • toStderr()
          • toStdout()
          • toSyslog()
        • TextLogger
          • log()
          • TextLogger()
          • toFile()
          • toHTTP()
          • toStderr()
          • toStdout()
          • toSyslog()
      • os
        • env
        • readDir()
        • readFile()
        • stat()
        • unlink()
        • writeFile()
      • pipy()
        • exit()
        • load()
        • restart()
        • solve()
      • stats
        • Counter
          • decrease()
          • increase()
          • Counter()
          • withLabels()
          • zero()
        • Gauge
          • decrease()
          • increase()
          • Gauge()
          • set()
          • withLabels()
          • zero()
        • Histogram
          • Histogram()
          • observe()
          • withLabels()
          • zero()
    • PipyJS
      • Language
      • Builtin Objects
      • NMI

    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 -h
    Usage: 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 : debuginfowarnerror.

    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.js
    2022-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 function
    2022-02-16 13:07:58.524 [ERR] [pjs] Backtrace:
    2022-02-16 13:07:58.524 [ERR] In (root) at line 4 column 13
    2022-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=6080
    2022-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 ::
    $ pipy
    2022-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: SIGTSTPSIGHUPSIGINT.

    $ 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 2
    pipy::Configuration 1
    pipy::Console 1
    pipy::Data 1
    pipy::Global 1
    pipy::Hessian 1
    pipy::Inbound 1
    pipy::JSON 1
    pipy::OS 1
    pipy::Pipy 1
    pipy::Pipy::Script 1
    pipy::Pipy::Store 1
    pipy::XML 1
    pipy::algo::Algo 1
    pipy::crypto::Crypto 1
    pipy::http::Http 1
    pjs::Constructor<pipy::Data> 1
    pjs::Constructor<pipy::Message> 1
    pjs::Constructor<pipy::MessageEnd> 1
    pjs::Constructor<pipy::MessageStart> 1
    pjs::Constructor<pipy::Netmask> 1
    pjs::Constructor<pipy::Session> 1
    pjs::Constructor<pipy::SessionEnd> 1
    pjs::Constructor<pipy::URL> 1
    pjs::Constructor<pipy::XML::Node> 1
    pjs::Constructor<pipy::algo::Cache> 1
    pjs::Constructor<pipy::algo::HashingLoadBalancer> 1
    pjs::Constructor<pipy::algo::LeastWorkLoadBalancer> 1
    pjs::Constructor<pipy::algo::Percentile> 1
    pjs::Constructor<pipy::algo::ResourcePool> 1
    pjs::Constructor<pipy::algo::RoundRobinLoadBalancer> 1
    pjs::Constructor<pipy::algo::URLRouter> 1
    pjs::Constructor<pipy::crypto::Certificate> 1
    pjs::Constructor<pipy::crypto::Cipher> 1
    pjs::Constructor<pipy::crypto::Decipher> 1
    pjs::Constructor<pipy::crypto::Hash> 1
    pjs::Constructor<pipy::crypto::Hmac> 1
    pjs::Constructor<pipy::crypto::JWK> 1
    pjs::Constructor<pipy::crypto::JWT> 1
    pjs::Constructor<pipy::crypto::PrivateKey> 1
    pjs::Constructor<pipy::crypto::PublicKey> 1
    pjs::Constructor<pipy::crypto::Sign> 1
    pjs::Constructor<pipy::crypto::Verify> 1
    pjs::Constructor<pipy::http::File> 1
    pjs::Constructor<pjs::Array> 1
    pjs::Constructor<pjs::Boolean> 1
    pjs::Constructor<pjs::Date> 1
    pjs::Constructor<pjs::Number> 1
    pjs::Constructor<pjs::Object> 1
    pjs::Constructor<pjs::RegExp> 1
    pjs::Constructor<pjs::String> 1
    pjs::Function 1
    TOTAL 53
    DATA CURRENT(KB) PEAK(KB)
    -----------------------------------------
    Codebase Service 0 0
    Cipher 0 0
    Decipher 0 0
    Hmac 0 0
    Hash 0 0
    Sign 0 0
    Verify 0 0
    http.File 0 0
    Codebase 4 4
    Codebase Store 0 0
    Unknown 0 0
    Script 0 0
    HTTP Encoder 0 0
    TLS 0 0
    Message 0 0
    TOTAL 4 n/a
    PIPELINE #ALLOCATED #ACTIVE
    -------------------------------------------
    /main.js [:::8080] 0 0
    TOTAL 0 0
    INBOUND #CONNECTIONS BUFFERED(KB)
    -------------------------------------
    8080 0/0 0
    TOTAL 0 0
    OUTBOUND #CONNECTIONS BUFFERED(KB) #OVERFLOWED MAX_CONN_TIME AVG_CONN_TIME
    ---------------------------------------------------------------------------------

    SIGHUP

    Pipy process reloads the codebase when it receives the SIGHUP signal.

    $ pipy main.js
    2022-02-16 13:19:51.301 [INF] [config]
    2022-02-16 13:19:51.302 [INF] [config] Module /main.js
    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] [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] serveHTTP
    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]
    2022-02-16 13:19:51.302 [INF] [listener] Listening on port 8080 at 0.0.0.0
    2022-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.js
    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] [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] serveHTTP
    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]
    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.


    © 2024, Flomesh Team.       ICP备案/许可证号:辽ICP备2023014827号