跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

autostart.go

60 行 · 2.0 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4// Package autostart manage start at login unit files for darwin/linux
5package autostart
6
7import (
8 "context"
9 "sync"
10
11 "github.com/lima-vm/lima/v2/pkg/limatype"
12)
13
14// IsRegistered checks if the instance is registered to start at login.
15func IsRegistered(ctx context.Context, inst *limatype.Instance) (bool, error) {
16 return manager().IsRegistered(ctx, inst)
17}
18
19// RegisterToStartAtLogin creates a start-at-login entry for the instance.
20func RegisterToStartAtLogin(ctx context.Context, inst *limatype.Instance) error {
21 return manager().RegisterToStartAtLogin(ctx, inst)
22}
23
24// UnregisterFromStartAtLogin deletes the start-at-login entry for the instance.
25func UnregisterFromStartAtLogin(ctx context.Context, inst *limatype.Instance) error {
26 return manager().UnregisterFromStartAtLogin(ctx, inst)
27}
28
29// AutoStartedIdentifier returns the identifier if the current process was started by the autostart manager.
30func AutoStartedIdentifier() string {
31 return manager().AutoStartedIdentifier()
32}
33
34// RequestStart requests to start the instance by identifier.
35func RequestStart(ctx context.Context, inst *limatype.Instance) error {
36 return manager().RequestStart(ctx, inst)
37}
38
39// RequestStop requests to stop the instance by identifier.
40func RequestStop(ctx context.Context, inst *limatype.Instance) (bool, error) {
41 return manager().RequestStop(ctx, inst)
42}
43
44type autoStartManager interface {
45 // Registration
46 IsRegistered(ctx context.Context, inst *limatype.Instance) (bool, error)
47 RegisterToStartAtLogin(ctx context.Context, inst *limatype.Instance) error
48 UnregisterFromStartAtLogin(ctx context.Context, inst *limatype.Instance) error
49
50 // Status
51 AutoStartedIdentifier() string
52
53 // Operation
54 // RequestStart requests to start the instance by identifier.
55 RequestStart(ctx context.Context, inst *limatype.Instance) error
56 // RequestStop requests to stop the instance by identifier.
57 RequestStop(ctx context.Context, inst *limatype.Instance) (bool, error)
58}
59
60var manager = sync.OnceValue(Manager)