feat: build entire backend into single executable (including migrations etc)
This commit is contained in:
parent
f94bc67f3d
commit
ded9d06e4a
12 changed files with 137 additions and 32 deletions
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package backend
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -12,14 +12,22 @@ import (
|
|||
|
||||
"github.com/go-chi/render"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var Command = &cli.Command{
|
||||
Name: "web",
|
||||
Usage: "Run the API server",
|
||||
Action: run,
|
||||
}
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
port := ":" + os.Getenv("PORT")
|
||||
|
||||
s, err := server.New()
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating server: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
// set render.Decode to a custom one that checks content length
|
||||
|
@ -44,10 +52,12 @@ func main() {
|
|||
case <-ctx.Done():
|
||||
log.Info("Interrupt signal received, shutting down...")
|
||||
s.DB.Close()
|
||||
return
|
||||
return nil
|
||||
case err := <-e:
|
||||
log.Fatalf("Error running server: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
const MaxContentLength = 2 * 1024 * 1024
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package backend
|
||||
|
||||
import (
|
||||
"codeberg.org/u1f320/pronouns.cc/backend/routes/auth"
|
||||
|
|
|
@ -16,7 +16,10 @@ import (
|
|||
)
|
||||
|
||||
// Revision is the git commit, filled at build time
|
||||
var Revision = "[unknown]"
|
||||
var (
|
||||
Revision = "[unknown]"
|
||||
Tag = "[unknown]"
|
||||
)
|
||||
|
||||
// Repository is the URL of the git repository
|
||||
const Repository = "https://codeberg.org/u1f320/pronouns.cc"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue