Skip to content

Use environment variable for server port#273

Merged
its-me-abhishek merged 1 commit intoCCExtractor:mainfrom
pfmephisto:pfmephisto-make-backend-port-configurable
Dec 13, 2025
Merged

Use environment variable for server port#273
its-me-abhishek merged 1 commit intoCCExtractor:mainfrom
pfmephisto:pfmephisto-make-backend-port-configurable

Conversation

@pfmephisto
Copy link
Copy Markdown
Contributor

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.

@github-actions
Copy link
Copy Markdown

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:

  • Check the "Files changed" tab
  • Leave comments on any lines for functions, comments, etc. that are important, non-obvious, or may need attention
  • Clarify decisions you made or areas you might be unsure about and/or any future updates being considered.
  • Finally, submit all the comments!

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!

Comment thread backend/main.go
Comment on lines +61 to +65
// Get port from environment or default to 8000
port := os.Getenv("CCSYNC_PORT")
if port == "" {
port = "8000"
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread backend/main.go Outdated
Comment on lines +110 to +112
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 {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here logging is amended to print the value of the given port. And the server is started using the port in question.

@its-me-abhishek
Copy link
Copy Markdown
Collaborator

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>
@pfmephisto pfmephisto force-pushed the pfmephisto-make-backend-port-configurable branch from dfc7373 to b99f3e6 Compare December 12, 2025 20:49
@pfmephisto
Copy link
Copy Markdown
Contributor Author

hi @its-me-abhishek thanks for the feedback, I pushed an updated version.

Copy link
Copy Markdown
Collaborator

@its-me-abhishek its-me-abhishek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@its-me-abhishek its-me-abhishek merged commit cac247e into CCExtractor:main Dec 13, 2025
4 checks passed
ShivaGupta-14 pushed a commit to ShivaGupta-14/ccsync that referenced this pull request Dec 25, 2025
Added environment variable support for server port.

Signed-off-by: mephisto <22501790+pfmephisto@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants