Lorenz Brun | c88c82d | 2020-05-08 14:35:04 +0200 | [diff] [blame^] | 1 | // Copyright 2020 The Monogon Project Authors. |
| 2 | // |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | |
| 17 | package containerd |
| 18 | |
| 19 | import ( |
| 20 | "context" |
| 21 | "os" |
| 22 | "os/exec" |
| 23 | |
| 24 | "git.monogon.dev/source/nexantic.git/core/pkg/logbuffer" |
| 25 | |
| 26 | "golang.org/x/sys/unix" |
| 27 | ) |
| 28 | |
| 29 | // Implements supervisor.Runnable for later integration |
| 30 | |
| 31 | func RunContainerd(ctx context.Context) error { |
| 32 | containerdLog := logbuffer.New(1000, 16384) |
| 33 | cmd := exec.CommandContext(ctx, "/containerd/bin/containerd", "--config", "/containerd/conf/config.toml") |
| 34 | cmd.Stdout = containerdLog |
| 35 | cmd.Stderr = containerdLog |
| 36 | cmd.Env = []string{"PATH=/containerd/bin", "TMPDIR=/containerd/run/tmp"} |
| 37 | |
| 38 | if err := unix.Mount("tmpfs", "/containerd/run", "tmpfs", 0, ""); err != nil { |
| 39 | panic(err) |
| 40 | } |
| 41 | if err := os.MkdirAll("/containerd/run/tmp", 0755); err != nil { |
| 42 | panic(err) |
| 43 | } |
| 44 | |
| 45 | // TODO(lorenz): Healthcheck against cri.Status() RPC |
| 46 | |
| 47 | return cmd.Run() |
| 48 | } |