some fixes
This commit is contained in:
parent
a1a335691d
commit
8e4afbede0
4 changed files with 13 additions and 39 deletions
|
|
@ -7,7 +7,6 @@ require (
|
|||
github.com/fsnotify/fsnotify v1.7.0
|
||||
golang.org/x/mod v0.21.0
|
||||
golang.org/x/net v0.29.0
|
||||
golang.org/x/sys v0.25.0
|
||||
golang.org/x/tools v0.25.0
|
||||
)
|
||||
|
||||
require golang.org/x/sys v0.25.0 // indirect
|
||||
|
|
|
|||
|
|
@ -55,15 +55,18 @@ func main() {
|
|||
slog.Debug("working dir:", slog.String("dir", process.GetWorkingDir()))
|
||||
|
||||
if taskName == "watch" {
|
||||
fmt.Printf("Running in watch mode\n")
|
||||
os.Setenv("ENV", "development")
|
||||
os.Setenv("WATCH_MODE", "true")
|
||||
fmt.Printf("Starting processes...")
|
||||
copyassets.CopyAssets()
|
||||
astgen.GenAst(process.ExitOnError)
|
||||
css.GenerateCss(process.ExitOnError, process.Silent)
|
||||
css.GenerateCss(process.ExitOnError)
|
||||
run.EntGenerate()
|
||||
go func() {
|
||||
css.GenerateCssWatch(process.ExitOnError)
|
||||
}()
|
||||
fmt.Printf("Starting server...\n")
|
||||
go func() {
|
||||
_ = run.Server()
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -90,22 +90,18 @@ func downloadTailwindCli() {
|
|||
}
|
||||
fileName := fmt.Sprintf(`tailwindcss-%s`, distro)
|
||||
url := fmt.Sprintf(`https://github.com/tailwindlabs/tailwindcss/releases/latest/download/%s`, fileName)
|
||||
if os == "windows" {
|
||||
process.RunMany([]string{
|
||||
fmt.Sprintf(`curl -LO %s`, url),
|
||||
}, process.ExitOnError)
|
||||
} else {
|
||||
process.RunMany([]string{
|
||||
fmt.Sprintf(`curl -LO %s`, url),
|
||||
fmt.Sprintf(`chmod +x %s`, fileName),
|
||||
}, process.ExitOnError)
|
||||
}
|
||||
process.Run(fmt.Sprintf(`curl -LO %s`, url), process.ExitOnError)
|
||||
|
||||
outputFileName := GetTailwindExecutableName()
|
||||
newPath := filepath.Join(process.GetWorkingDir(), outputFileName)
|
||||
|
||||
err := dirutil.MoveFile(
|
||||
filepath.Join(process.GetWorkingDir(), fileName),
|
||||
filepath.Join(process.GetWorkingDir(), outputFileName))
|
||||
newPath)
|
||||
|
||||
if os != "windows" {
|
||||
err = process.Run(fmt.Sprintf(`chmod +x %s`, newPath), process.ExitOnError)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Error moving file: %s\n", err.Error())
|
||||
|
|
|
|||
|
|
@ -1,15 +1,9 @@
|
|||
package h
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/maddalax/htmgo/framework/hx"
|
||||
"github.com/maddalax/htmgo/framework/internal/process"
|
||||
"github.com/maddalax/htmgo/framework/service"
|
||||
"log/slog"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
type RequestContext struct {
|
||||
|
|
@ -92,25 +86,7 @@ func (a App) start() {
|
|||
err := a.Echo.Start(port)
|
||||
|
||||
if err != nil {
|
||||
// If we are in watch mode, just try to kill any processes holding that port
|
||||
// and try again
|
||||
if IsDevelopment() && IsWatchMode() {
|
||||
slog.Info("Port already in use, trying to kill the process and start again")
|
||||
if runtime.GOOS == "windows" {
|
||||
cmd := exec.Command("cmd", "/C", fmt.Sprintf(`for /F "tokens=5" %%i in ('netstat -aon ^| findstr :%s') do taskkill /F /PID %%i`, port))
|
||||
cmd.Run()
|
||||
} else {
|
||||
process.RunOrExit(fmt.Sprintf("kill -9 $(lsof -t -i%s)", port))
|
||||
}
|
||||
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
err = a.Echo.Start(port)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue