Skip to content

Commit de3969f

Browse files
authored
Merge pull request #8 from ara-framework/feat/custom-port
Feat/custom port
2 parents 76bfd66 + 34ddbd0 commit de3969f

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
config.json
1+
config.json
2+
build

build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
package_name="nova-proxy"
3+
4+
5+
platforms=("windows/amd64" "windows/386" "darwin/amd64")
6+
7+
for platform in "${platforms[@]}"
8+
do
9+
platform_split=(${platform//\// })
10+
GOOS=${platform_split[0]}
11+
GOARCH=${platform_split[1]}
12+
output_name=$package_name'-'$GOOS'-'$GOARCH
13+
if [ $GOOS = "windows" ]; then
14+
output_name+='.exe'
15+
fi
16+
17+
env GOOS=$GOOS GOARCH=$GOARCH go build -o build/$output_name
18+
if [ $? -ne 0 ]; then
19+
echo 'An error has occurred! Aborting the script execution...'
20+
exit 1
21+
fi
22+
done

main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package main
33
import (
44
"log"
55
"net/http"
6+
"os"
67

78
"github.com/ara-framework/nova-proxy/config"
9+
"github.com/gookit/color"
810
)
911

1012
func init() {
@@ -14,5 +16,13 @@ func init() {
1416

1517
func main() {
1618
config.SetUpLocations()
17-
log.Fatal(http.ListenAndServe(":8080", nil))
19+
20+
port := os.Getenv("PORT")
21+
22+
if len(port) == 0 {
23+
port = "8080"
24+
}
25+
26+
color.Info.Printf("Nova proxy running on http://0.0.0.0:%s\n", port)
27+
log.Fatal(http.ListenAndServe(":"+port, nil))
1828
}

0 commit comments

Comments
 (0)