Added base worker file
This commit is contained in:
parent
f43e2630a2
commit
cf3c2ddb19
39
cmd/worker/main.go
Normal file
39
cmd/worker/main.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"flag"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Command line flags
|
||||
dbPath := flag.String("db", "data.db", "path to SQLite database")
|
||||
pollInterval := flag.Duration("poll", 100*time.Millisecond, "polling interval")
|
||||
flag.Parse()
|
||||
|
||||
// Initialize database connection
|
||||
db, err := sql.Open("sqlite3", *dbPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to open database: %v", err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
// Test database connection
|
||||
if err := db.Ping(); err != nil {
|
||||
log.Fatalf("Failed to ping database: %v", err)
|
||||
}
|
||||
|
||||
log.Printf("Worker started with polling interval: %v", *pollInterval)
|
||||
|
||||
// Main worker loop
|
||||
for {
|
||||
// TODO: Write code here
|
||||
|
||||
// Sleep for the specified interval
|
||||
time.Sleep(*pollInterval)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user