siked f29d3fc0bc master | 11 months ago | |
---|---|---|
.. | ||
config | 11 months ago | |
context | 11 months ago | |
ctl | 11 months ago | |
service | 11 months ago | |
README.MD | 11 months ago | |
RunCode.go | 11 months ago | |
打包镜像.MD | 11 months ago |
在线运行代码 服务依赖docker环境
go run main.go --port=端口号 --config=配置文件路径
编辑docker_config.json
文件 添加对应 key value 即可
{
"docker_runner": {
"go": {
"ext": "go",
"filename": "main.go",
"image": "golang:1.18.0-alpine3.15",
"cmd": "go run main.go"
}
}
}
docker_runner
字段说明
字段名 | 说明 |
---|---|
ext | 文件后续 |
filename | 容器中运行的文件名 |
image | 镜像名 |
cmd | 启动容器后运行的命令 |
获取所有支持的语言列表
GET /languages
[
"go",
"python",
"php",
"java",
"node"
]
POST /run?lang={lang}
请求体:具体代码
{
"lang": "{lang}",
"message": "execute success",
"result": "hello world"
}
Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
sudo vim /etc/default/grub 替换: GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" sudo update-grub reboot