Files
Abiola IbrahimandGitHub f499e12c3f v0.6.0 refactor (#848)
* core: begin migration to ubuntu

* core: update cloud image link

* k3s: update version

* core: fix boot for ubuntu

* vm: add ability to set custom hostname

* core: checkpoint: remove qemu wrapper

* core: checkpoint: remove qemu wrapper

* cli: minor bug fix for terminal output

* cli: fix broken terminal output for deb download

* cli: improve terminal output for deb download

* vm: fix docker permission on initial create

* net: remove gvproxy, migrate to user-v2

* docker: fix host-gateway address

* vm: avoid re-installing packages

* k3s: fix broken coredns

* core: improve downloader

* vm: add binfmt for cross-platform containers

* containerd: fix for ubuntu

* containerd: fix broken working directory detection

* chore: remove obsolete env var

* chore: minor refactor for binfmt

* cli: fix ip address for colima list

* docker: add daemon support for proxy env vars

* vm: add more utilities

* ci: remove obsolete ubuntu layer

* ci: move to gh from hub

* core: use custom directory for Lima

* chore: minor factor, remove obsolete variable

* docker: workaround initial user permission issue

* chore: remove obsolete code

* vm: fix binfmt cache

* core: enforce Lima version requirement

* docker: workaround permission issue

* vm: enable inotify by default

* core: enable binfmt only on host arch

* docs: prepare for v0.6.0

* nix: update Go version in shell

* nix: update build

* build: add integration test script

* ci: remove aarch64, defer until proper m1 support

* build: fix colima path in integration test script
2023-11-12 11:28:30 +01:00

104 lines
2.5 KiB
Go

package daemon
import (
"context"
"time"
"github.com/abiosoft/colima/cmd/root"
"github.com/abiosoft/colima/config"
"github.com/abiosoft/colima/daemon/process"
"github.com/abiosoft/colima/daemon/process/inotify"
"github.com/abiosoft/colima/daemon/process/vmnet"
"github.com/abiosoft/colima/environment/host"
"github.com/abiosoft/colima/environment/vm/lima"
"github.com/spf13/cobra"
)
var daemonCmd = &cobra.Command{
Use: "daemon",
Short: "daemon",
Long: `runner for background daemons.`,
Hidden: true,
}
var startCmd = &cobra.Command{
Use: "start [profile]",
Short: "start daemon",
Long: `start the daemon`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
config.SetProfile(args[0])
ctx := cmd.Context()
var processes []process.Process
if daemonArgs.vmnet {
processes = append(processes, vmnet.New())
}
if daemonArgs.inotify.enabled {
processes = append(processes, inotify.New())
guest := lima.New(host.New())
args := inotify.Args{
GuestActions: guest,
Runtime: daemonArgs.inotify.runtime,
Dirs: daemonArgs.inotify.dirs,
}
ctx = context.WithValue(ctx, inotify.CtxKeyArgs(), args)
}
return start(ctx, processes)
},
}
var stopCmd = &cobra.Command{
Use: "stop [profile]",
Short: "stop daemon",
Long: `stop the daemon`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
config.SetProfile(args[0])
// wait for 60 seconds
timeout := time.Second * 60
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
return stop(ctx)
},
}
var statusCmd = &cobra.Command{
Use: "status",
Short: "status of the daemon",
Long: `status of the daemon`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
config.SetProfile(args[0])
return status()
},
}
var daemonArgs struct {
vmnet bool
inotify struct {
enabled bool
dirs []string
runtime string
}
verbose bool
}
func init() {
root.Cmd().AddCommand(daemonCmd)
daemonCmd.AddCommand(startCmd)
daemonCmd.AddCommand(stopCmd)
daemonCmd.AddCommand(statusCmd)
startCmd.Flags().BoolVar(&daemonArgs.vmnet, "vmnet", false, "start vmnet")
startCmd.Flags().BoolVar(&daemonArgs.inotify.enabled, "inotify", false, "start inotify")
startCmd.Flags().StringSliceVar(&daemonArgs.inotify.dirs, "inotify-dir", nil, "set inotify directories")
startCmd.Flags().StringVar(&daemonArgs.inotify.runtime, "inotify-runtime", "docker", "set runtime")
}