mirror of
https://github.com/criyle/go-judge.git
synced 2025-09-26 22:39:12 +08:00
docs: fix typos
This commit is contained in:
parent
505994205f
commit
8025bd36b6
@ -306,7 +306,7 @@ Output:
|
||||
|
||||
</details>
|
||||
|
||||
Plese use PostMan or similar tools to send request to `http://localhost:5050/run`
|
||||
Please use PostMan or similar tools to send request to `http://localhost:5050/run`
|
||||
|
||||
<details><summary>Single (this example require `apt install g++` inside the container)</summary>
|
||||
|
||||
@ -613,7 +613,7 @@ Sandbox:
|
||||
- for example, by default container 0 will run with 10001 uid & gid and container 1 will run with 10002 uid & gid...
|
||||
- `-enable-cpu-rate` enabled `cpu` cgroup to control cpu rate using cfs_quota & cfs_period control (Linux only)
|
||||
- `-cpu-cfs-period` specifies cfs_period if cpu rate is enabled (default 100ms) (valid value: \[1ms, 1s\])
|
||||
- `-seccomp-conf` specifies `seecomp` filter setting to load when running program (need build tag `seccomp`) (Linux only)
|
||||
- `-seccomp-conf` specifies `seccomp` filter setting to load when running program (need build tag `seccomp`) (Linux only)
|
||||
- for example, by `strace -c prog` to get all `syscall` needed and restrict to that sub set
|
||||
- however, the `syscall` count in one platform(e.g. x86_64) is not suitable for all platform, so this option is not recommended
|
||||
- the program killed by seccomp filter will have status `Dangerous Syscall`
|
||||
@ -707,7 +707,7 @@ If a bind mount is specifying a target within the previous mounted one, please e
|
||||
#### Windows Security
|
||||
|
||||
- Resources are limited by [JobObject](https://docs.microsoft.com/en-us/windows/win32/procthread/job-objects)
|
||||
- Privillege are limited by [Restricted Low Mandatory Level Token](https://docs.microsoft.com/en-us/windows/win32/secauthz/access-tokens)
|
||||
- Privilege are limited by [Restricted Low Mandatory Level Token](https://docs.microsoft.com/en-us/windows/win32/secauthz/access-tokens)
|
||||
- Low Mandatory Level directory is created for read / write
|
||||
|
||||
### MacOS Support
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
srvAddr = flag.String("srvaddr", "localhost:5051", "GRPC server addr")
|
||||
srvAddr = flag.String("srv-addr", "localhost:5051", "GRPC server addr")
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -32,7 +32,7 @@ type Config struct {
|
||||
OutputLimit *envexec.Size `flagUsage:"specifies POSIX rlimit for output for each command" default:"256m"`
|
||||
CopyOutLimit *envexec.Size `flagUsage:"specifies default file copy out max" default:"256m"`
|
||||
OpenFileLimit int `flagUsage:"specifies max open file count" default:"256"`
|
||||
Cpuset string `flagUsage:"control the usage of cpuset for all containerd process"`
|
||||
Cpuset string `flagUsage:"control the usage of cpuset for all container process"`
|
||||
EnableCPURate bool `flagUsage:"enable cpu cgroup rate control"`
|
||||
CPUCfsPeriod time.Duration `flagUsage:"set cpu.cfs_period" default:"100ms"`
|
||||
FileTimeout time.Duration `flagUsage:"specified timeout for filestore files"`
|
||||
@ -44,7 +44,7 @@ type Config struct {
|
||||
MonitorAddr string `flagUsage:"specifies the metrics binding address"`
|
||||
AuthToken string `flagUsage:"bearer token auth for REST / gRPC"`
|
||||
EnableDebug bool `flagUsage:"enable debug endpoint"`
|
||||
EnableMetrics bool `flagUsage:"enable promethus metrics endpoint"`
|
||||
EnableMetrics bool `flagUsage:"enable prometheus metrics endpoint"`
|
||||
|
||||
// logger config
|
||||
Release bool `flagUsage:"release level of logs"`
|
||||
|
@ -4,13 +4,10 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
crypto_rand "crypto/rand"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
math_rand "math/rand"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"os"
|
||||
@ -53,13 +50,12 @@ var logger *zap.Logger
|
||||
func main() {
|
||||
conf := loadConf()
|
||||
if conf.Version {
|
||||
fmt.Print(version.Version)
|
||||
fmt.Println(version.Version)
|
||||
return
|
||||
}
|
||||
initLogger(conf)
|
||||
defer logger.Sync()
|
||||
logger.Sugar().Infof("config loaded: %+v", conf)
|
||||
initRand()
|
||||
warnIfNotLinux()
|
||||
|
||||
// Init environment pool
|
||||
@ -69,7 +65,7 @@ func main() {
|
||||
prefork(envPool, conf.PreFork)
|
||||
work := newWorker(conf, envPool, fs)
|
||||
work.Start()
|
||||
logger.Sugar().Infof("Started worker with parallelism=%d, workdir=%s, timeLimitCheckInterval=%v",
|
||||
logger.Sugar().Infof("Started worker with parallelism=%d, workDir=%s, timeLimitCheckInterval=%v",
|
||||
conf.Parallelism, conf.Dir, conf.TimeLimitCheckerInterval)
|
||||
|
||||
servers := []initFunc{
|
||||
@ -272,17 +268,6 @@ func initLogger(conf *config.Config) {
|
||||
}
|
||||
}
|
||||
|
||||
func initRand() {
|
||||
var b [8]byte
|
||||
_, err := crypto_rand.Read(b[:])
|
||||
if err != nil {
|
||||
logger.Fatal("random generator init failed ", zap.Error(err))
|
||||
}
|
||||
sd := int64(binary.LittleEndian.Uint64(b[:]))
|
||||
logger.Sugar().Infof("random seed: %d", sd)
|
||||
math_rand.Seed(sd)
|
||||
}
|
||||
|
||||
func prefork(envPool worker.EnvironmentPool, prefork int) {
|
||||
if prefork <= 0 {
|
||||
return
|
||||
@ -469,7 +454,7 @@ func newEnvBuilder(conf *config.Config) (pool.EnvBuilder, map[string]any) {
|
||||
logger.Sugar().Fatal("create environment builder failed ", err)
|
||||
}
|
||||
if conf.EnableMetrics {
|
||||
b = &metriceEnvBuilder{b}
|
||||
b = &metricsEnvBuilder{b}
|
||||
}
|
||||
return b, param
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ var (
|
||||
Namespace: metricsNamespace,
|
||||
Subsystem: execSubsystem,
|
||||
Name: "memory_bytes",
|
||||
Help: "Histgram for the command execution max memory",
|
||||
Help: "Histogram for the command execution max memory",
|
||||
Buckets: memoryBucket,
|
||||
}, []string{"status"})
|
||||
|
||||
@ -57,7 +57,7 @@ var (
|
||||
Namespace: metricsNamespace,
|
||||
Subsystem: filestoreSubsystem,
|
||||
Name: "size_bytes",
|
||||
Help: "Histgram for the file size created in the file store",
|
||||
Help: "Histogram for the file size created in the file store",
|
||||
Buckets: fileSizeBucket,
|
||||
})
|
||||
|
||||
@ -171,13 +171,13 @@ func (m *metricsFileStore) Remove(id string) bool {
|
||||
return success
|
||||
}
|
||||
|
||||
var _ pool.EnvBuilder = &metriceEnvBuilder{}
|
||||
var _ pool.EnvBuilder = &metricsEnvBuilder{}
|
||||
|
||||
type metriceEnvBuilder struct {
|
||||
type metricsEnvBuilder struct {
|
||||
pool.EnvBuilder
|
||||
}
|
||||
|
||||
func (b *metriceEnvBuilder) Build() (pool.Environment, error) {
|
||||
func (b *metricsEnvBuilder) Build() (pool.Environment, error) {
|
||||
e, err := b.EnvBuilder.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
4
env/linuxcontainer/environment_linux.go
vendored
4
env/linuxcontainer/environment_linux.go
vendored
@ -30,7 +30,7 @@ type environ struct {
|
||||
cpuRate bool
|
||||
}
|
||||
|
||||
// Destroy destories the environment
|
||||
// Destroy destroys the environment
|
||||
func (c *environ) Destroy() error {
|
||||
return c.Environment.Destroy()
|
||||
}
|
||||
@ -131,7 +131,7 @@ func (c *environ) Open(path string, flags int, perm os.FileMode) (*os.File, erro
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// MkdirAll equivelent to os.MkdirAll but in container
|
||||
// MkdirAll equivalent to os.MkdirAll but in container
|
||||
func (c *environ) MkdirAll(path string, perm os.FileMode) error {
|
||||
if path == "" || path == "." {
|
||||
return nil
|
||||
|
2
env/macsandbox/profile_darwin.go
vendored
2
env/macsandbox/profile_darwin.go
vendored
@ -52,7 +52,7 @@ type Profile struct {
|
||||
Network bool
|
||||
}
|
||||
|
||||
// DefaultProfile defines the minimun default profile to run programs
|
||||
// DefaultProfile defines the minimum default profile to run programs
|
||||
var DefaultProfile = Profile{
|
||||
ReadableDir: []string{"/usr/lib"},
|
||||
}
|
||||
|
4
env/winc/process_windows.go
vendored
4
env/winc/process_windows.go
vendored
@ -27,14 +27,14 @@ func (p *process) Result() envexec.RunnerResult {
|
||||
}
|
||||
|
||||
func (p *process) Usage() envexec.Usage {
|
||||
t, m, _ := getJobOjbectUsage(p.hJob)
|
||||
t, m, _ := getJobObjectUsage(p.hJob)
|
||||
return envexec.Usage{
|
||||
Time: t,
|
||||
Memory: m,
|
||||
}
|
||||
}
|
||||
|
||||
func getJobOjbectUsage(hJob windows.Handle) (time.Duration, envexec.Size, error) {
|
||||
func getJobObjectUsage(hJob windows.Handle) (time.Duration, envexec.Size, error) {
|
||||
basicInfo := new(JOBOBJECT_BASIC_ACCOUNTING_INFORMATION)
|
||||
if _, err := QueryInformationJobObject(hJob, JobObjectBasicAccountingInformation,
|
||||
uintptr(unsafe.Pointer(basicInfo)), uint32(unsafe.Sizeof(*basicInfo)), nil); err != nil {
|
||||
|
@ -53,7 +53,7 @@ type Cmd struct {
|
||||
CopyOut []CmdCopyOutFile
|
||||
CopyOutMax Size // file size limit
|
||||
|
||||
// CopyOutDir specifies a dir to dump all /w contnet
|
||||
// CopyOutDir specifies a dir to dump all /w content
|
||||
CopyOutDir string
|
||||
|
||||
// additional memory option
|
||||
|
@ -34,7 +34,7 @@ type Pipe struct {
|
||||
// Name defines copy out entry name if it is not empty and proxy is enabled
|
||||
Name string
|
||||
|
||||
// Limit defines maximun bytes copy out from proxy and proxy will still
|
||||
// Limit defines maximum bytes copy out from proxy and proxy will still
|
||||
// copy data after limit exceeded
|
||||
Limit Size
|
||||
|
||||
|
@ -14,7 +14,7 @@ var (
|
||||
_ heap.Interface = &Timeout{}
|
||||
)
|
||||
|
||||
// Timeout is a file system with a maximun TTL
|
||||
// Timeout is a file system with a maximum TTL
|
||||
type Timeout struct {
|
||||
mu sync.Mutex
|
||||
FileStore
|
||||
@ -28,7 +28,7 @@ type timeoutFile struct {
|
||||
time time.Time
|
||||
}
|
||||
|
||||
// NewTimeout creates a timeout file system with maximun TTL for a file
|
||||
// NewTimeout creates a timeout file system with maximum TTL for a file
|
||||
func NewTimeout(fs FileStore, timeout time.Duration, checkInterval time.Duration) FileStore {
|
||||
t := &Timeout{
|
||||
FileStore: fs,
|
||||
|
Loading…
Reference in New Issue
Block a user