-
Notifications
You must be signed in to change notification settings - Fork 3
/
serviceVM_todeScript.st
78 lines (75 loc) · 2.64 KB
/
serviceVM_todeScript.st
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[ :topez :objIn :tokens :command :commandNode |
| opts args cmd |
"for help: ./serviceVM -h"
cmd := command command.
command
getOptsMixedLongShort:
{#('help' $h #'none').
#('register' nil #'none').
#('force' nil #'none').
#('start' nil #'none').
#('status' nil #'none').
#('stop' nil #'none').
#('restart' nil #'none')}
optionsAndArguments: [ :options :operands |
opts := options.
args := operands ].
opts
at: 'help'
ifAbsent: [
| server serviceName response |
serviceName := 'ServiceVM-ServiceVM'.
server := WAGemStoneRunSmalltalkServer serverNamed: serviceName.
response := server.
opts
at: 'status'
ifPresent: [ :ignored |
server isNil
ifTrue: [ response := 'Web server not registered' ]
ifFalse: [ WAGemStoneRunSmalltalkServer statusGems: server ].
response ]
ifAbsent: [
opts
at: 'register'
ifPresent: [ :ignored |
opts
at: 'force'
ifPresent: [ :ignored2 | server ifNotNil: [ WAGemStoneRunSmalltalkServer removeServerNamed: serviceName ] ].
WAGemStoneRunSmalltalkServer
addServerOfClass: WAGemStoneServiceExampleVM
withName: serviceName
on: #(0). "port required, but not used by service vm"
server := WAGemStoneRunSmalltalkServer serverNamed: serviceName.
response := server ].
opts at: 'port' ifPresent: [ :port | server ports: {(port asNumber)} ].
opts
at: 'start'
ifPresent: [ :ignored | WAGemStoneRunSmalltalkServer startGems: server ]
ifAbsent: [
opts
at: 'restart'
ifPresent: [ :ignored | WAGemStoneRunSmalltalkServer restartGems: server ]
ifAbsent: [
opts
at: 'stop'
ifPresent: [ :ignored | WAGemStoneRunSmalltalkServer stopGems: server ]
ifAbsent: [ ] ] ] ].
response ]
ifPresent: [ :ignored |
TDManPage
viewManPage:
'NAME
serviceVM - control server gem for WAGemStoneServiceExampleVM example
SYNOPSIS
serviceVM [-h|--help] [--register [--force]] [--start] [--stop] [--restart]
DESCRIPTION
EXAMPLES
./serviceVM --help
./serviceVM --register # register a new instance (first time)
./serviceVM --register --force # force a new registration (override existing)
./serviceVM --restart # restart service gem
./serviceVM --start # start service gem
./serviceVM --status # status of service gem
./serviceVM --stop # stop service gem
'
topez: topez ] ]