Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nixpig committed Dec 22, 2024
1 parent 2a4c9d7 commit 5f41858
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ audit:

.PHONY: build
build:
go build -o tmp/bin/brownie main.go
CGO_ENABLED=1 go build -o tmp/bin/brownie main.go

.PHONY: test
test:
Expand All @@ -29,11 +29,11 @@ coveralls:

.PHONY: run
run:
go run ./...
CGO_ENABLED=1 go run ./...

.PHONY: watch
watch:
go run github.com/cosmtrek/[email protected] \
CGO_ENABLED=1 go run github.com/cosmtrek/[email protected] \
--build.cmd "make build" \
--build.bin "tmp/bin/brownie" \
--build.delay "100" \
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: <<-SHELL
set -e -x -o pipefail
apt-get update && apt-get install -y ca-certificates wget make vim libseccomp-dev
apt-get update && apt-get install -y ca-certificates wget make vim gcc libseccomp-dev
# Install docker
if ! command -v docker 2>&1 >/dev/null; then
Expand Down
2 changes: 1 addition & 1 deletion container/container_reexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (c *Container) Reexec() error {
filepath.Join(containerRootDir, c.ID(), initSockFilename),
)
if err != nil {
return err
return fmt.Errorf("reexec dial init sock: %w", err)
}

initConn.Write([]byte("ready"))
Expand Down
4 changes: 1 addition & 3 deletions filesystem/mount_options.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package filesystem

import (
"golang.org/x/sys/unix"
)
import "golang.org/x/sys/unix"

var MountOptions = map[string]struct {
No bool
Expand Down
17 changes: 13 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@ package main

import (
"fmt"
"io"
"log/slog"
"os"

"github.com/nixpig/brownie/internal/cli"
"github.com/thediveo/gons"
)

func main() {
// check namespace status
log, err := os.OpenFile("/var/log/brownie.log", os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
fmt.Println("open log file: ", err)
os.Exit(1)
}

logger := slog.New(slog.NewTextHandler(io.MultiWriter(log, os.Stdout), nil))
slog.SetDefault(logger)

if err := gons.Status(); err != nil {
fmt.Println("join namespace(s): ", err)
slog.Error("join namespace(s)", slog.String("err", err.Error()))
os.Exit(1)
}

// exec root
if err := cli.RootCmd().Execute(); err != nil {
fmt.Println(fmt.Errorf("%s, %w", os.Args, err))
slog.Error("root exec", slog.String("err", err.Error()))
os.Exit(1)
}

Expand Down
2 changes: 0 additions & 2 deletions terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,5 @@ func Setup(rootfs, consoleSocketPath string) (*int, error) {
return nil, fmt.Errorf("change back to previos cwd: %w", err)
}

// TODO: close?

return &consoleSocket.SocketFd, nil
}

0 comments on commit 5f41858

Please sign in to comment.