diff --git a/.gitignore b/.gitignore index 0cffcb3..bf2d1cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -config.json \ No newline at end of file +config.json +build \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cfc6498 --- /dev/null +++ b/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +package_name="nova-proxy" + + +platforms=("windows/amd64" "windows/386" "darwin/amd64") + +for platform in "${platforms[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + output_name=$package_name'-'$GOOS'-'$GOARCH + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + + env GOOS=$GOOS GOARCH=$GOARCH go build -o build/$output_name + if [ $? -ne 0 ]; then + echo 'An error has occurred! Aborting the script execution...' + exit 1 + fi +done \ No newline at end of file diff --git a/main.go b/main.go index 3f17016..cc87e68 100644 --- a/main.go +++ b/main.go @@ -3,8 +3,10 @@ package main import ( "log" "net/http" + "os" "github.com/ara-framework/nova-proxy/config" + "github.com/gookit/color" ) func init() { @@ -14,5 +16,13 @@ func init() { func main() { config.SetUpLocations() - log.Fatal(http.ListenAndServe(":8080", nil)) + + port := os.Getenv("PORT") + + if len(port) == 0 { + port = "8080" + } + + color.Info.Printf("Nova proxy running on http://0.0.0.0:%s\n", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) }