Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open project on start #53

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions cmd/hetty/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"crypto/tls"
"flag"
"log"
Expand All @@ -27,6 +28,7 @@ var (
caCertFile string
caKeyFile string
projPath string
projName string
addr string
adminPath string
)
Expand All @@ -35,6 +37,7 @@ func main() {
flag.StringVar(&caCertFile, "cert", "~/.hetty/hetty_cert.pem", "CA certificate filepath. Creates a new CA certificate is file doesn't exist")
flag.StringVar(&caKeyFile, "key", "~/.hetty/hetty_key.pem", "CA private key filepath. Creates a new CA private key if file doesn't exist")
flag.StringVar(&projPath, "projects", "~/.hetty/projects", "Projects directory path")
flag.StringVar(&projName, "project", "", "Project to open on start")
flag.StringVar(&addr, "addr", ":8080", "TCP address to listen on, in the form \"host:port\"")
flag.StringVar(&adminPath, "adminPath", "", "File path to admin build")
flag.Parse()
Expand Down Expand Up @@ -71,6 +74,13 @@ func main() {
}
defer projService.Close()

if projName != "" {
_, err = projService.Open(context.Background(), projName)
if err != nil {
log.Fatalf("[FATAL] Could not open project: %v", err)
}
}

scope := scope.New(db, projService)

reqLogService := reqlog.NewService(reqlog.Config{
Expand Down