Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions internal/gounicorn/gounicorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import (
"goauthentik.io/internal/utils"
)

var (
manageCmd string = "./manage.py"
gunicornCmd string = "gunicorn"
gunicornConf string = "./lifecycle/gunicorn.conf.py"
pidDir string = ""
)

type GoUnicorn struct {
Healthcheck func() bool
healthyCallbacks []func()
Expand Down Expand Up @@ -58,16 +65,16 @@ func New(healthcheck func() bool) *GoUnicorn {
}

func (g *GoUnicorn) initCmd() {
command := "./manage.py"
command := manageCmd
Copy link
Member

Choose a reason for hiding this comment

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

I dont think this is required for this, since manage.py is only used during development where you're probably running go run ./cmd/server

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointer, I didn't realize it was overwritten after !config.Get().Debug. I think it might still be useful though if trying to debug against the system Python environment?

args := []string{"dev_server"}
if !config.Get().Debug {
pidFile, err := os.CreateTemp("", "authentik-gunicorn.*.pid")
pidFile, err := os.CreateTemp(pidDir, "authentik-gunicorn.*.pid")
Copy link
Member

Choose a reason for hiding this comment

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

Might not be needed since that'll just use TMP by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was actually the reason, because I try to avoid storing files in world-writable directories. Indeed it could be set using TMPDIR, but it's not ideal because it would still default to /tmp on most systems if not set.

if err != nil {
panic(fmt.Errorf("failed to create temporary pid file: %v", err))
}
g.pidFile = pidFile.Name()
command = "gunicorn"
args = []string{"-c", "./lifecycle/gunicorn.conf.py", "authentik.root.asgi:application"}
command = gunicornCmd
args = []string{"-c", gunicornConf, "authentik.root.asgi:application"}
if g.pidFile != "" {
args = append(args, "--pid", g.pidFile)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/web/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (ws *WebServer) configureStatic() {
staticRouter.Use(ws.staticHeaderMiddleware)
staticRouter.Use(web.DisableIndex)

distFs := http.FileServer(http.Dir("./web/dist"))
distFs := http.FileServer(staticWeb.StaticDir)

pathStripper := func(handler http.Handler, paths ...string) http.Handler {
h := handler
Expand Down
4 changes: 3 additions & 1 deletion web/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var RobotsTxt []byte
//go:embed security.txt
var SecurityTxt []byte

var StaticDir = http.Dir("./web/dist/")
var staticDir = "./web/dist/"

var StaticDir = http.Dir(staticDir)

var StaticHandler = http.FileServer(StaticDir)
Loading