💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] > [joewalnes/websocketd](https://github.com/joewalnes/websocketd) ## 概述 它的最大特点,就是后台脚本不限语言,标准输入(stdin)就是 WebSocket 的输入,标准输出(stdout)就是 WebSocket 的输出。 ## 示例 ### hello world <details> <summary>counter.sh</summary> ``` #!/bin/bash echo 1 sleep 1 echo 2 sleep 1 echo 3 ``` </details> <br /> <details> <summary>index.hhtml</summary> ``` var ws = new WebSocket('ws://localhost:8080/'); ws.onmessage = function(event) { console.log(event.data); }; ``` </details> <br /> 运行 ``` > websocketd --port=8080 bash ./counter.sh ``` ### 监控服务器 > [github](https://github.com/joewalnes/web-vmstats) ![](https://github.com/joewalnes/web-vmstats/raw/master/screenshot.png) vmstat 指令 ``` $ vmstat 1 procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 3 0 43652 2742600 453820 2829164 0 0 1 10 0 0 6 1 93 0 1 0 43652 2742784 453820 2829164 0 0 0 0 3106 5701 11 1 87 0 0 0 43652 2742908 453820 2829164 0 0 0 0 3898 6703 11 2 87 0 1 0 43652 2743672 453820 2829164 0 0 0 32 3844 6708 11 2 87 0 2 0 43652 2743980 453820 2829164 0 0 0 80 4130 7164 11 2 87 0 ``` 运行 run 文件 ``` #!/bin/sh # Download websocketd for your platform from # https://github.com/joewalnes/websocketd/wiki/Download-and-install ./websocketd --port=9231 --staticdir=web /usr/bin/vmstat -n 1 ``` 执行 ``` ./run ```