Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Castellum
castellum_scheduler
Commits
e3232dce
Commit
e3232dce
authored
Aug 31, 2021
by
Bengfort
Browse files
use environment variables instead of command line flags
parent
0bd23860
Changes
1
Hide whitespace changes
Inline
Side-by-side
broker/broker.go
View file @
e3232dce
package
main
import
(
"flag"
"fmt"
"io/ioutil"
"log"
...
...
@@ -191,19 +190,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
}
func
main
()
{
flag
.
Usage
=
func
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
"foo [-v] [port]
\n
"
)
flag
.
PrintDefaults
()
}
flag
.
BoolVar
(
&
verbose
,
"v"
,
false
,
"enable verbose logs"
)
flag
.
Parse
()
addr
:=
"localhost:8001"
if
len
(
flag
.
Args
())
>
0
{
addr
=
fmt
.
Sprintf
(
"localhost:%s"
,
flag
.
Args
()[
0
])
port
,
ok
:=
os
.
LookupEnv
(
"BROKER_PORT"
)
if
ok
{
addr
=
fmt
.
Sprintf
(
"localhost:%s"
,
port
)
}
_
,
verbose
=
os
.
LookupEnv
(
"BROKER_VERBOSE"
)
http
.
HandleFunc
(
"/"
,
handler
)
log
.
Printf
(
"Serving on http://%s"
,
addr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment