Skip to content

Commit

Permalink
Prepare for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
olzhasar committed Mar 9, 2024
1 parent b7fa79c commit 498f3c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
frontend/
gochat
*_test.go
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ go.work
*.db-journal
*.sqlite3
*.sqlite3-journal

gochat
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"github.com/gorilla/websocket"
"log"
"net/http"
"os"

"github.com/gorilla/websocket"
)

type Client struct {
Expand Down Expand Up @@ -114,8 +116,14 @@ func readMessages(server *Server, client *Client) {
}

func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}

server := NewServer()
go server.listen()

log.Fatal(http.ListenAndServe(":8080", server))
log.Println("Starting server on port", port)
log.Fatal(http.ListenAndServe(":"+port, server))
}

0 comments on commit 498f3c0

Please sign in to comment.