Files
wehub-resource-sync e0e362d700
SDK Tests / SDK CI (push) Blocked by required conditions
SDK Tests / changes (push) Successful in 2m29s
Real E2E Tests / changes (push) Successful in 2m29s
SDK Tests / Python SDK Tests (sandbox) (push) Waiting to run
SDK Tests / CLI Quality (push) Waiting to run
SDK Tests / CLI Tests (push) Waiting to run
SDK Tests / Python SDK Quality (code-interpreter) (push) Waiting to run
SDK Tests / Python SDK Quality (sandbox) (push) Waiting to run
SDK Tests / Python SDK Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Go SDK Quality And Tests (push) Waiting to run
Deploy Docs Pages / build (push) Has been cancelled
Deploy Docs Pages / deploy (push) Has been cancelled
Real E2E Tests / JavaScript E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Python E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Java E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / C# E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Go E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Real E2E CI (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:33 +08:00

108 lines
3.2 KiB
Go

// Copyright 2025 Alibaba Group Holding Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"context"
"fmt"
"net"
"os"
"time"
"github.com/alibaba/opensandbox/internal/version"
_ "github.com/alibaba/opensandbox/internal/safego"
_ "go.uber.org/automaxprocs/maxprocs"
"github.com/alibaba/opensandbox/execd/pkg/clone3compat"
"github.com/alibaba/opensandbox/execd/pkg/flag"
"github.com/alibaba/opensandbox/execd/pkg/isolation"
"github.com/alibaba/opensandbox/execd/pkg/log"
"github.com/alibaba/opensandbox/execd/pkg/runtime"
"github.com/alibaba/opensandbox/execd/pkg/telemetry"
"github.com/alibaba/opensandbox/execd/pkg/web"
"github.com/alibaba/opensandbox/execd/pkg/web/controller"
)
func main() {
clone3Compat := clone3compat.MaybeApply()
version.EchoVersion("OpenSandbox Execd")
flag.InitFlags()
// Load isolation config.
isoCfg, err := isolation.LoadConfig(flag.IsolationConfigPath)
if err != nil {
log.Error("isolation: config: %v", err)
os.Exit(1)
}
// Probe isolation runtime capabilities.
isolationProbe := isolation.Probe(isolation.ProbeConfig{
UpperRoot: isoCfg.UpperRoot,
UpperMaxBytes: isoCfg.UpperMaxBytes,
})
log.Info("isolation: available=%v isolator=%s version=%s",
isolationProbe.Available, isolationProbe.Isolator, isolationProbe.Version)
log.Init(flag.ServerLogLevel)
ctrl := controller.InitCodeRunner()
// Always store probe result for capabilities endpoint.
controller.InitIsolatedProbe(&isolationProbe)
// Init isolation runner if probe succeeded.
if isolationProbe.Available {
iso := isolation.NewBwrap(isoCfg)
runner, err := runtime.NewIsolatedRunner(ctrl, iso, isoCfg)
if err != nil {
log.Error("isolation: runner init failed (continuing without isolation): %v", err)
} else {
controller.InitIsolatedRunner(runner)
log.Info("isolation: runner ready, upper_root=%s", isoCfg.UpperRoot)
}
}
if clone3Compat {
log.Warn("execd running with clone3 compatibility (seccomp returns ENOSYS for clone3)")
}
otelShutdown, err := telemetry.Init(context.Background())
if err != nil {
log.Warn("OpenTelemetry metrics disabled (continuing without OTLP): %v", err)
otelShutdown = nil
}
if otelShutdown != nil {
defer func() {
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_ = otelShutdown(shutdownCtx)
}()
}
engine := web.NewRouter(flag.ServerAccessToken)
addr := fmt.Sprintf(":%d", flag.ServerPort)
listener, err := net.Listen("tcp4", addr)
if err != nil {
log.Error("failed to listen on %s: %v", addr, err)
os.Exit(1)
}
log.Info("execd listening on %s (IPv4)", addr)
if err := engine.RunListener(listener); err != nil {
log.Error("failed to start execd server: %v", err)
os.Exit(1)
}
}