mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
support starting a service
This commit is contained in:
parent
b4509fb45e
commit
2f08e0942a
6 changed files with 41 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ logs:
|
||||||
commandTemplates:
|
commandTemplates:
|
||||||
dockerCompose: docker-compose
|
dockerCompose: docker-compose
|
||||||
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
|
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
|
||||||
|
startService: '{{ .DockerCompose }} start {{ .Service.Name }}'
|
||||||
stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}'
|
stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}'
|
||||||
serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}'
|
serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}'
|
||||||
viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}'
|
viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}'
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,16 @@ func (s *Service) Restart() error {
|
||||||
return s.OSCommand.RunCommand(command)
|
return s.OSCommand.RunCommand(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restart starts the service
|
||||||
|
func (s *Service) Start() error {
|
||||||
|
templateString := s.OSCommand.Config.UserConfig.CommandTemplates.StartService
|
||||||
|
command := utils.ApplyTemplate(
|
||||||
|
templateString,
|
||||||
|
s.DockerCommand.NewCommandObject(CommandObject{Service: s}),
|
||||||
|
)
|
||||||
|
return s.OSCommand.RunCommand(command)
|
||||||
|
}
|
||||||
|
|
||||||
// Attach attaches to the service
|
// Attach attaches to the service
|
||||||
func (s *Service) Attach() (*exec.Cmd, error) {
|
func (s *Service) Attach() (*exec.Cmd, error) {
|
||||||
return s.Container.Attach()
|
return s.Container.Attach()
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,9 @@ type CommandTemplatesConfig struct {
|
||||||
// .Service.Name }}
|
// .Service.Name }}
|
||||||
RestartService string `yaml:"restartService,omitempty"`
|
RestartService string `yaml:"restartService,omitempty"`
|
||||||
|
|
||||||
|
// StartService is just like the above but for starting
|
||||||
|
StartService string `yaml:"startService,omitempty"`
|
||||||
|
|
||||||
// DockerCompose is for your docker-compose command. You may want to combine a
|
// DockerCompose is for your docker-compose command. You may want to combine a
|
||||||
// few different docker-compose.yml files together, in which case you can set
|
// few different docker-compose.yml files together, in which case you can set
|
||||||
// this to "docker-compose -f foo/docker-compose.yml -f
|
// this to "docker-compose -f foo/docker-compose.yml -f
|
||||||
|
|
@ -326,6 +329,7 @@ func GetDefaultConfig() UserConfig {
|
||||||
CommandTemplates: CommandTemplatesConfig{
|
CommandTemplates: CommandTemplatesConfig{
|
||||||
DockerCompose: "docker-compose",
|
DockerCompose: "docker-compose",
|
||||||
RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}",
|
RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}",
|
||||||
|
StartService: "{{ .DockerCompose }} start {{ .Service.Name }}",
|
||||||
RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}",
|
RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}",
|
||||||
RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}",
|
RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}",
|
||||||
StopService: "{{ .DockerCompose }} stop {{ .Service.Name }}",
|
StopService: "{{ .DockerCompose }} stop {{ .Service.Name }}",
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleServiceRestart,
|
Handler: gui.handleServiceRestart,
|
||||||
Description: gui.Tr.Restart,
|
Description: gui.Tr.Restart,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "services",
|
||||||
|
Key: 'S',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleServiceStart,
|
||||||
|
Description: gui.Tr.Start,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "services",
|
ViewName: "services",
|
||||||
Key: 'a',
|
Key: 'a',
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,21 @@ func (gui *Gui) handleServiceRestart(g *gocui.Gui, v *gocui.View) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleServiceStart(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
service, err := gui.getSelectedService()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return gui.WithWaitingStatus(gui.Tr.StartingStatus, func() error {
|
||||||
|
if err := service.Start(); err != nil {
|
||||||
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleServiceAttach(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleServiceAttach(g *gocui.Gui, v *gocui.View) error {
|
||||||
service, err := gui.getSelectedService()
|
service, err := gui.getSelectedService()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ type TranslationSet struct {
|
||||||
FocusMain string
|
FocusMain string
|
||||||
StopContainer string
|
StopContainer string
|
||||||
RestartingStatus string
|
RestartingStatus string
|
||||||
|
StartingStatus string
|
||||||
StoppingStatus string
|
StoppingStatus string
|
||||||
RemovingStatus string
|
RemovingStatus string
|
||||||
RunningCustomCommandStatus string
|
RunningCustomCommandStatus string
|
||||||
|
|
@ -47,6 +48,7 @@ type TranslationSet struct {
|
||||||
RemoveService string
|
RemoveService string
|
||||||
Stop string
|
Stop string
|
||||||
Restart string
|
Restart string
|
||||||
|
Start string
|
||||||
Rebuild string
|
Rebuild string
|
||||||
Recreate string
|
Recreate string
|
||||||
PreviousContext string
|
PreviousContext string
|
||||||
|
|
@ -108,6 +110,7 @@ func englishSet() TranslationSet {
|
||||||
PruningStatus: "pruning",
|
PruningStatus: "pruning",
|
||||||
RemovingStatus: "removing",
|
RemovingStatus: "removing",
|
||||||
RestartingStatus: "restarting",
|
RestartingStatus: "restarting",
|
||||||
|
StartingStatus: "starting",
|
||||||
StoppingStatus: "stopping",
|
StoppingStatus: "stopping",
|
||||||
RunningCustomCommandStatus: "running custom command",
|
RunningCustomCommandStatus: "running custom command",
|
||||||
RunningBulkCommandStatus: "running bulk command",
|
RunningBulkCommandStatus: "running bulk command",
|
||||||
|
|
@ -144,6 +147,7 @@ func englishSet() TranslationSet {
|
||||||
RemoveService: "remove containers",
|
RemoveService: "remove containers",
|
||||||
Stop: "stop",
|
Stop: "stop",
|
||||||
Restart: "restart",
|
Restart: "restart",
|
||||||
|
Start: "start",
|
||||||
Rebuild: "rebuild",
|
Rebuild: "rebuild",
|
||||||
Recreate: "recreate",
|
Recreate: "recreate",
|
||||||
PreviousContext: "previous tab",
|
PreviousContext: "previous tab",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue