Use environment variable for server port#273
Conversation
|
Thank you for opening this PR! Before a maintainer takes a look, it would be really helpful if you could walk through your changes using GitHub's review tools. Please take a moment to:
This helps make the review process smoother and gives us a clearer understanding of your thought process. Once you've added your self-review, we'll continue from our side. Thank you! |
| // Get port from environment or default to 8000 | ||
| port := os.Getenv("CCSYNC_PORT") | ||
| if port == "" { | ||
| port = "8000" | ||
| } |
There was a problem hiding this comment.
This gets the value of the environment variable CCSYNC_PORT and in case it is unset (and empty string) it's set the the previous hard-coded value of 8000
| utils.Logger.Infof("Server started at :%s", port) | ||
| utils.Logger.Infof("API documentation available at http://localhost:%s/api/docs/index.html", port) | ||
| if err := http.ListenAndServe(":" + port, app.EnableCORS(mux)); err != nil { |
There was a problem hiding this comment.
Here logging is amended to print the value of the given port. And the server is started using the port in question.
|
hi @pfmephisto thanks for the PR, please run the go format command once to make the lint check pass. also please if possible add some info about this variable inside ./backend/readme with a note/comment that - this variable will work only if we run the backend directly --- and will need to tweak the docker-compose if we want to use this var port while using the setup in ./production or the local docker setup. will merge once this is done. |
Added environment variable support for server port. Signed-off-by: mephisto <22501790+pfmephisto@users.noreply.github.com>
dfc7373 to
b99f3e6
Compare
|
hi @its-me-abhishek thanks for the feedback, I pushed an updated version. |
Added environment variable support for server port. Signed-off-by: mephisto <22501790+pfmephisto@users.noreply.github.com>
Summary
Add support for configuring the server port via the CCSYNC_PORT environment variable, with a default of 8000 when unset.
Motivation
Needed for packaging ccsync on NixOS so the service port can be set to a custom value and avoid conflicts with other system services.