@@ -108,16 +108,6 @@ func main() {
108108 reloadEvent := u .NewAtomicEvent [bool ]()
109109 go watchConfigFile (* cfile , reloadEvent )
110110
111- // Start the web server in a separate goroutine.
112- http .Handle ("/" , http .FileServer (http .Dir ("./web" )))
113- http .HandleFunc ("/api/config" , c .ConfigHandler (* cfile ))
114- go func () {
115- slog .Info ("Starting web server" , "address" , "http://localhost:8080" )
116- if err := http .ListenAndServe (":8080" , nil ); err != nil {
117- slog .Error ("Web server failed" , "error" , err )
118- }
119- }()
120-
121111 signal .Notify (ossignal , os .Interrupt )
122112
123113 for {
@@ -326,6 +316,17 @@ func (a *App) initialise(cfile string, realp bool, sensp bool) error {
326316
327317 go a .combineAndUpdateDisplay (ledReader , ledBufferPool )
328318 go a .stateManager ()
319+
320+ // Start the web server in a separate goroutine.
321+ http .Handle ("/" , http .FileServer (http .Dir ("./web" )))
322+ http .HandleFunc ("/api/config" , c .ConfigHandler (cfile ))
323+ go func () {
324+ slog .Info ("Starting web server" , "address" , "http://localhost:8080" )
325+ if err := http .ListenAndServe (fmt .Sprintf (":%d" , conf .Hardware .WebserverPort ), nil ); err != nil {
326+ slog .Error ("Web server failed" , "error" , err )
327+ }
328+ }()
329+
329330 return nil
330331}
331332
0 commit comments