2024-05-18 01:00:59 +09:00
//go:build !js
2024-05-03 02:47:30 +09:00
2022-05-18 00:04:37 +09:00
package workers
import (
"fmt"
"net/http"
2024-05-18 01:00:59 +09:00
"os"
2024-01-24 22:05:49 +09:00
)
2022-05-18 00:04:37 +09:00
2024-05-18 01:00:59 +09:00
// Server serves http.Handler as a normal HTTP server.
2022-05-18 00:04:37 +09:00
// if the given handler is nil, http.DefaultServeMux will be used.
2024-05-18 01:00:59 +09:00
// As a port number, PORT environment variable or default value (9900) is used.
// This function is implemented for non-JS environments for debugging purposes.
2022-05-18 00:04:37 +09:00
func Serve ( handler http . Handler ) {
if handler == nil {
handler = http . DefaultServeMux
}
2024-05-18 01:00:59 +09:00
port := os . Getenv ( "PORT" )
if port == "" {
port = "9900"
}
addr := fmt . Sprintf ( ":%s" , port )
fmt . Printf ( "listening on: http://localhost%s\n" , addr )
fmt . Fprintln ( os . Stderr , "warn: this server is currently running in non-JS mode. to enable JS-related features, please use the make command in the syumai/workers template." )
http . ListenAndServe ( addr , handler )
2022-05-18 00:04:37 +09:00
}
2024-11-08 01:46:52 +09:00
func ServeNonBlock ( http . Handler ) {
panic ( "ServeNonBlock is not supported in non-JS environments" )
}
func Ready ( ) {
panic ( "Ready is not supported in non-JS environments" )
}
func WaitForCompletion ( ) {
panic ( "WaitForCompletion is not supported in non-JS environments" )
}