|  | hace 2 años | |
|---|---|---|
| .. | ||
| config | hace 2 años | |
| context | hace 2 años | |
| ctl | hace 2 años | |
| service | hace 2 años | |
| README.MD | hace 2 años | |
| RunCode.go | hace 2 años | |
| 打包镜像.MD | hace 2 años | |
在线运行代码 服务依赖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