Fetch the repository succeeded.
This action will force synchronization from tupelo-shen/mysnapd, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package ctlcmd
import (
"fmt"
"sort"
"text/tabwriter"
"gitee.com/mysnapcore/mysnapd/client/clientutil"
"gitee.com/mysnapcore/mysnapd/i18n"
"gitee.com/mysnapcore/mysnapd/overlord/servicestate"
"gitee.com/mysnapcore/mysnapd/progress"
"gitee.com/mysnapcore/mysnapd/snap"
)
var (
shortServicesHelp = i18n.G("Query the status of services")
longServicesHelp = i18n.G(`
The services command lists information about the services specified.
`)
)
func init() {
addCommand("services", shortServicesHelp, longServicesHelp, func() command { return &servicesCommand{} })
}
type servicesCommand struct {
baseCommand
Positional struct {
ServiceNames []string `positional-arg-name:"<service>"`
} `positional-args:"yes"`
}
type byApp []*snap.AppInfo
func (a byApp) Len() int { return len(a) }
func (a byApp) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byApp) Less(i, j int) bool {
return a[i].Name < a[j].Name
}
func (c *servicesCommand) Execute([]string) error {
context, err := c.ensureContext()
if err != nil {
return err
}
st := context.State()
svcInfos, err := getServiceInfos(st, context.InstanceName(), c.Positional.ServiceNames)
if err != nil {
return err
}
sort.Sort(byApp(svcInfos))
sd := servicestate.NewStatusDecorator(progress.Null)
services, err := clientutil.ClientAppInfosFromSnapAppInfos(svcInfos, sd)
if err != nil || len(services) == 0 {
return err
}
w := tabwriter.NewWriter(c.stdout, 5, 3, 2, ' ', 0)
defer w.Flush()
fmt.Fprintln(w, i18n.G("Service\tStartup\tCurrent\tNotes"))
for _, svc := range services {
startup := i18n.G("disabled")
if svc.Enabled {
startup = i18n.G("enabled")
}
current := i18n.G("inactive")
if svc.DaemonScope == snap.UserDaemon {
current = "-"
} else if svc.Active {
current = i18n.G("active")
}
fmt.Fprintf(w, "%s.%s\t%s\t%s\t%s\n", svc.Snap, svc.Name, startup, current, clientutil.ClientAppInfoNotes(&svc))
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。