-
Notifications
You must be signed in to change notification settings - Fork 19
/
restartService.go
42 lines (38 loc) · 1.01 KB
/
restartService.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"os"
"github.com/Symantec/Dominator/lib/filesystem"
"github.com/Symantec/Dominator/lib/srpc"
"github.com/Symantec/Dominator/lib/triggers"
"github.com/Symantec/Dominator/proto/sub"
"github.com/Symantec/Dominator/sub/client"
)
func restartServiceSubcommand(getSubClient getSubClientFunc, args []string) {
if err := restartService(getSubClient(), args[0]); err != nil {
logger.Fatalf("Error deleting: %s\n", err)
}
os.Exit(0)
}
func restartService(srpcClient *srpc.Client, serviceName string) error {
tmpPathname := fmt.Sprintf("/subtool-restart-%d", os.Getpid())
return client.CallUpdate(srpcClient, sub.UpdateRequest{
Wait: true,
InodesToMake: []sub.Inode{
{
Name: tmpPathname,
GenericInode: &filesystem.RegularInode{},
},
},
PathsToDelete: []string{tmpPathname},
Triggers: &triggers.Triggers{
Triggers: []*triggers.Trigger{
{
MatchLines: []string{tmpPathname},
Service: serviceName,
},
},
},
},
&sub.UpdateResponse{})
}