-
-
Notifications
You must be signed in to change notification settings - Fork 578
INFO log does not display correct port when starting buffalo dev #2151
Comments
Yeah, Indeed. the output is not correct. I think we need to fix it to match the reality. However, from my quick investigation, I found that it uses an interface for the server ( Is there any reason you used $ PORT=8001 buffalo dev
<...>
Starting application at http://127.0.0.1:8001 |
This patch could be a quick fix for the issue if we really need to allow the manual assigning of the address. Or, keep the current behavior as is, and documenting the behavior could be another solution for this. --- buffalo/server.go 2021-10-19 22:50:58.659821065 +0900
+++ [email protected]/server.go 2021-10-23 18:22:37.082807523 +0900
@@ -19,7 +19,7 @@
// interrupt and kill signals and will attempt to stop the application
// gracefully. This will also start the Worker process, unless WorkerOff is enabled.
func (a *App) Serve(srvs ...servers.Server) error {
- a.Logger.Infof("Starting application at http://%s", a.Options.Addr)
+ a.Logger.Infof("Starting application")
payload := events.Payload{
"app": a,
@@ -84,6 +84,7 @@
}
for _, s := range srvs {
+ a.Logger.Infof("Starting application server at %v", s.GetAddr())
s.SetAddr(a.Addr)
go func(s servers.Server) {
if err := s.Start(ctx, a); err != nil {
--- buffalo/servers/listener.go 2021-10-19 22:50:58.659821065 +0900
+++ [email protected]/servers/listener.go 2021-10-23 17:29:48.173865901 +0900
@@ -19,6 +19,10 @@
}
}
+func (s *Listener) GetAddr() string {
+ return s.Server.Addr
+}
+
// Start the server
func (s *Listener) Start(c context.Context, h http.Handler) error {
s.Handler = h
--- buffalo/servers/servers.go 2021-10-19 22:50:58.659821065 +0900
+++ [email protected]/servers/servers.go 2021-10-23 17:27:11.996470557 +0900
@@ -11,6 +11,7 @@
Shutdown(context.Context) error
Start(context.Context, http.Handler) error
SetAddr(string)
+ GetAddr() string
}
// Wrap converts a standard *http.Server to a buffalo.Server
--- buffalo/servers/simple.go 2021-10-19 22:50:58.659821065 +0900
+++ [email protected]/servers/simple.go 2021-10-23 18:19:44.243387725 +0900
@@ -17,6 +17,10 @@
}
}
+func (s *Simple) GetAddr() string {
+ return s.Server.Addr
+}
+
// Start the server
func (s *Simple) Start(c context.Context, h http.Handler) error {
s.Handler = h
--- buffalo/servers/tls.go 2021-10-19 22:50:58.659821065 +0900
+++ [email protected]/servers/tls.go 2021-10-23 18:20:03.283762539 +0900
@@ -19,6 +19,10 @@
}
}
+func (s *TLS) GetAddr() string {
+ return s.Server.Addr
+}
+
// Start the server
func (s *TLS) Start(c context.Context, h http.Handler) error {
s.Handler = h |
You're right. What I suggest is unnecessary. |
I didn't intend to say your suggestion is unnecessary since indeed the information on the log is not correct. I would like to keep watching this issue and fix the issue until the wrong log to be fixed. :-) |
Description
If you set the port, the command
buffalo dev
does not display the correct port.Steps to Reproduce the Problem
Use this to change the port number:
Expected Behavior
on
buffalo dev
, the startup log should read:INFO[2021-10-23T14:10:32+09:00] Starting application at 127.0.0.1:8001
Actual Behavior
on
buffalo dev
, the startup log actually read:INFO[2021-10-23T14:10:32+09:00] Starting application at 127.0.0.1:3000
Info
Please run
buffalo info
and paste the information below where it says "PASTE_HERE".The text was updated successfully, but these errors were encountered: