Skip to content

flytrap/web-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web-rpc

通过 web 接口远程执行命令, 用于解决容器内部需要调用宿主机命令的情况

启动命令

go run main.go web -c config.json

调用

curl --location --request POST 'localhost:8080/api/rpc/v1/run/reloadNginx'

配置

commands

  • code: 命令代码
  • exec: 具体命令字符串

编译

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/web-rpc-linux .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o build/web-rpc-darwin .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o build/web-rpc.exe .

开机启动

/etc/systemd/system/web-rpc.service

[Unit]
Description=web rpc Service
After=network.target

[Service]
Type=web-rpc
ExecStart=/usr/bin/web-rpc web -c /etc/web-rpc/config.json
User=root

[Install]
WantedBy=multi-user.target

查看日志:

journalctl -u web-rpc

About

通过web接口远程执行命令, 用于解决容器内部需要调用宿主机命令的情况

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages