-
Notifications
You must be signed in to change notification settings - Fork 3
/
webServer_todeScript.st
82 lines (81 loc) · 2.69 KB
/
webServer_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
79
80
81
82
[ :topez :objIn :tokens :command :commandNode |
| opts args cmd |
"for help: ./webServer -h"
cmd := command command.
command
getOptsMixedLongShort:
{#('help' $h #'none').
#('register' nil #'required').
#('port' nil #'required').
#('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 |
serviceName := 'ServiceVM-WebServer'.
server := WAGemStoneRunSmalltalkServer serverNamed: serviceName.
opts
at: 'status'
ifPresent: [ :ignored |
| response |
server isNil
ifTrue: [ response := 'Web server not registered' ]
ifFalse: [ WAGemStoneRunSmalltalkServer statusGems: server ].
response ]
ifAbsent: [
opts
at: 'register'
ifPresent: [ :serverType |
| serverClass |
serverType = 'zinc'
ifTrue: [ serverClass := WAGsZincAdaptor ]
ifFalse: [
serverType = 'fastcgi'
ifTrue: [ serverClass := WAFastCGIAdaptor ]
ifFalse: [
serverType = 'swazoo'
ifTrue: [ serverClass := WAGsSwazooAdaptor ]
ifFalse: [ self error: 'Unknown web server type ' , serverType printString ] ] ].
WAGemStoneRunSmalltalkServer
addServerOfClass: serverClass
withName: serviceName
on: #(8383).
server := WAGemStoneRunSmalltalkServer serverNamed: serviceName ].
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: [ ] ] ] ] ]
ifPresent: [ :ignored |
TDManPage
viewManPage:
'NAME
webServer - control Zinc-based web server for ServiceVM example
SYNOPSIS
webServer [-h|--help] [--register=zinc|fastcgi|swazoo] [--port=<port-number>]
[--start] [--stop] [--restart]
DESCRIPTION
EXAMPLES
./webServer --help
./webServer --register=zinc --port=8383 --start
./webServer --port=8383
./webServer --restart
./webServer --start
./webServer --status
./webServer --stop
'
topez: topez ] ]