mirror of
https://github.com/criyle/go-judge.git
synced 2025-09-26 22:39:12 +08:00
feat: support -copy-in-dir for easier debugging (#155)
Some checks are pending
Build / Goreleaser (push) Waiting to run
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (amd64_v3, darwin) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (amd64_v3, linux) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (amd64_v3, windows) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (arm64_v8.0, darwin) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (arm64_v8.0, linux) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (arm64_v8.0, windows) (push) Blocked by required conditions
Some checks are pending
Build / Goreleaser (push) Waiting to run
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (amd64_v3, darwin) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (amd64_v3, linux) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (amd64_v3, windows) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (arm64_v8.0, darwin) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (arm64_v8.0, linux) (push) Blocked by required conditions
Build / Upload artifacts-${{ matrix.os }}-${{ matrix.arch }} (arm64_v8.0, windows) (push) Blocked by required conditions
* feat: support -copy-in-dir for easier debugging * fix: use relative path
This commit is contained in:
parent
6bf9f2e224
commit
6211423165
@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ var (
|
|||||||
transport = flag.String("transport", "websocket", "defines transport layer (websocket / grpc)")
|
transport = flag.String("transport", "websocket", "defines transport layer (websocket / grpc)")
|
||||||
wsURL = flag.String("ws-url", "ws://localhost:5050/stream", "HTTP server url")
|
wsURL = flag.String("ws-url", "ws://localhost:5050/stream", "HTTP server url")
|
||||||
grpcAddr = flag.String("grpc-addr", "localhost:5051", "GRPC server addr")
|
grpcAddr = flag.String("grpc-addr", "localhost:5051", "GRPC server addr")
|
||||||
|
copyInDir = flag.String("copy-in-dir", "", "directory to copy files from")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -61,6 +63,27 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run(sc Stream, args []string) (*model.Response, error) {
|
func run(sc Stream, args []string) (*model.Response, error) {
|
||||||
|
copyIn := make(map[string]model.CmdFile, 0)
|
||||||
|
if *copyInDir != "" {
|
||||||
|
_ = filepath.Walk(*copyInDir,
|
||||||
|
func(path string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
absPath, err := filepath.Abs(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
relPath, err := filepath.Rel(*copyInDir, path)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if !info.IsDir() {
|
||||||
|
copyIn[relPath] = model.CmdFile{Src: &absPath}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
req := model.Request{
|
req := model.Request{
|
||||||
Cmd: []model.Cmd{{
|
Cmd: []model.Cmd{{
|
||||||
Args: args,
|
Args: args,
|
||||||
@ -70,6 +93,7 @@ func run(sc Stream, args []string) (*model.Response, error) {
|
|||||||
{StreamOut: true},
|
{StreamOut: true},
|
||||||
{StreamOut: true},
|
{StreamOut: true},
|
||||||
},
|
},
|
||||||
|
CopyIn: copyIn,
|
||||||
CPULimit: uint64(cpuLimit.Nanoseconds()),
|
CPULimit: uint64(cpuLimit.Nanoseconds()),
|
||||||
ClockLimit: uint64(sessionLimit.Nanoseconds()),
|
ClockLimit: uint64(sessionLimit.Nanoseconds()),
|
||||||
MemoryLimit: memoryLimit,
|
MemoryLimit: memoryLimit,
|
||||||
|
Loading…
Reference in New Issue
Block a user