Compare commits

...

2 Commits

5 changed files with 20 additions and 8 deletions

View File

@ -42,7 +42,7 @@ live/sync_assets:
--build.include_dir "assets" \
--build.include_ext "js,css"
# start all 6 watch processes in parallel.
# start all 5 watch processes in parallel.
live:
ENVIRONMENT="DEVELOPMENT" make -j5 live/tailwind live/templ live/server live/esbuild live/sync_assets

View File

@ -9,7 +9,7 @@ This project provides a comprehensive internet speed monitoring solution by:
## Usage
1. Go to the [releases tab](/releases/latest)
1. Go to the [releases tab](releases/latest)
1. download the latest version
1. execute the binary
1. wait for data (like 5min)

View File

@ -6,16 +6,18 @@ import (
"log"
"time"
"gitea.zokki.net/zokki/speed-tester/models"
_ "github.com/mattn/go-sqlite3" // Import the SQLite driver
"github.com/showwin/speedtest-go/speedtest"
"gitea.zokki.net/zokki/speed-tester/flag"
"gitea.zokki.net/zokki/speed-tester/models"
)
var DB *sql.DB
func init() {
var err error
DB, err = sql.Open("sqlite3", "./speed-data.db")
DB, err = sql.Open("sqlite3", *flag.DbPath)
if err != nil {
panic(err)
}

8
flag/flag.go Normal file
View File

@ -0,0 +1,8 @@
package flag
import "flag"
var (
Port = flag.Int("port", 9512, "port to serve the web-application")
DbPath = flag.String("db-path", "./speed-data.db", "the path to the SQLite database")
)

10
main.go
View File

@ -2,16 +2,18 @@ package main
import (
"embed"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
"gitea.zokki.net/zokki/speed-tester/database"
"gitea.zokki.net/zokki/speed-tester/routes"
_ "github.com/mattn/go-sqlite3" // Import the SQLite driver
"github.com/showwin/speedtest-go/speedtest"
"gitea.zokki.net/zokki/speed-tester/database"
"gitea.zokki.net/zokki/speed-tester/flag"
"gitea.zokki.net/zokki/speed-tester/routes"
)
var isDev = strings.ToUpper(os.Getenv("ENVIRONMENT")) == "DEVELOPMENT"
@ -46,7 +48,7 @@ func main() {
}
server := http.Server{
Addr: ":9512",
Addr: fmt.Sprintf(":%d", *flag.Port),
Handler: router,
}