Skip to content

Commit 363f1a4

Browse files
authored
adds application control (start, stop, restart) commands (#43)
This commit adds new commands for controlling platform applications. It adds the following commands: - `start application ...` - `stop application...` - `restart application ...`
1 parent 160e4bf commit 363f1a4

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

internal/handlers/descriptors/adapters.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ edit:
5050
#############################################################################
5151
# Import/Export commands
5252
#############################################################################
53+
5354
import:
5455
use: adapter <name>
5556
group: admin-essentials

internal/handlers/descriptors/applications.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,20 @@ inspect:
77
use: applications
88
description: |
99
Show application status
10+
11+
start:
12+
use: application <name>
13+
description: |
14+
Start a stopped application
15+
16+
stop:
17+
use: application <name>
18+
description: |
19+
Stop a running application
20+
21+
restart:
22+
use: application <name>
23+
description: |
24+
Restart an application
25+
26+

internal/runners/applications.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,48 @@ func NewApplicationRunner(c client.Client, cfg *config.Config) *ApplicationRunne
2727
}
2828
}
2929

30+
func (r *ApplicationRunner) Start(in Request) (*Response, error) {
31+
logger.Trace()
32+
33+
name := in.Args[0]
34+
35+
if err := r.service.Start(name); err != nil {
36+
return nil, err
37+
}
38+
39+
return NewResponse(
40+
fmt.Sprintf("Successfully started application `%s`", name),
41+
), nil
42+
}
43+
44+
func (r *ApplicationRunner) Stop(in Request) (*Response, error) {
45+
logger.Trace()
46+
47+
name := in.Args[0]
48+
49+
if err := r.service.Stop(name); err != nil {
50+
return nil, err
51+
}
52+
53+
return NewResponse(
54+
fmt.Sprintf("Successfully stopped application `%s`", name),
55+
), nil
56+
}
57+
58+
func (r *ApplicationRunner) Restart(in Request) (*Response, error) {
59+
logger.Trace()
60+
61+
name := in.Args[0]
62+
63+
if err := r.service.Restart(name); err != nil {
64+
return nil, err
65+
}
66+
67+
return NewResponse(
68+
fmt.Sprintf("Successfully restarted application `%s`", name),
69+
), nil
70+
}
71+
3072
func (r *ApplicationRunner) Inspect(in Request) (*Response, error) {
3173
logger.Trace()
3274

0 commit comments

Comments
 (0)