File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,11 @@ The [examples](examples/) directory contains complete example code.
49
49
To run the simple [ helloworld] ( examples/helloworld/main.go ) example:
50
50
``` bash
51
51
# Run __without__ sigsci enabled
52
- go run examples/helloworld/main.go
52
+ go run examples/helloworld/main.go localhost:8000
53
53
# Run with sigsci-agent listening via a UNIX Domain socket file
54
- go run examples/helloworld/main.go /var/run/sigsci.sock
54
+ go run examples/helloworld/main.go localhost:8000 /var/run/sigsci.sock
55
55
# Run with sigsci-agent listening via a TCP address:port
56
- go run examples/helloworld/main.go localhost:9999
56
+ go run examples/helloworld/main.go localhost:8000 localhost: 9999
57
57
```
58
58
59
59
This will run a HTTP listener on ` localhost:8000 ` , which will send any
Original file line number Diff line number Diff line change @@ -11,11 +11,20 @@ import (
11
11
)
12
12
13
13
func main () {
14
+ // Get the listener address from the first arg
15
+ listenerAddress := ""
16
+ if len (os .Args ) > 1 {
17
+ listenerAddress = os .Args [1 ]
18
+ }
19
+ if len (listenerAddress ) == 0 {
20
+ listenerAddress = "localhost:8000"
21
+ }
22
+
14
23
// Process sigsci-agent rpc-address if passed
15
24
sigsciAgentNetwork := "unix"
16
25
sigsciAgentAddress := ""
17
- if len (os .Args ) > 1 {
18
- sigsciAgentAddress = os .Args [1 ]
26
+ if len (os .Args ) > 2 {
27
+ sigsciAgentAddress = os .Args [2 ]
19
28
}
20
29
if ! strings .Contains (sigsciAgentAddress , "/" ) {
21
30
sigsciAgentNetwork = "tcp"
@@ -56,7 +65,7 @@ func main() {
56
65
// Listen and Serve as usual using the wrapped sigsci handler if enabled
57
66
s := & http.Server {
58
67
Handler : handler ,
59
- Addr : "localhost:8000" ,
68
+ Addr : listenerAddress ,
60
69
}
61
70
log .Printf ("Server URL: http://%s/" , s .Addr )
62
71
log .Fatal (s .ListenAndServe ())
You can’t perform that action at this time.
0 commit comments