shithub: hugo

Download patch

ref: 9349a889e2bf6262681164f41c9221a382fd57ae
parent: ff4ca992869cdbcc9f2ce06c9a2f9857a0b95910
author: Bjørn Erik Pedersen <[email protected]>
date: Sat Feb 27 11:58:42 EST 2016

Do not try to find available port if set by user

He/she probably really meant it.

Fixes #1901

--- a/commands/server.go
+++ b/commands/server.go
@@ -118,6 +118,10 @@
 	if err == nil {
 		l.Close()
 	} else {
+		if flagChanged(serverCmd.Flags(), "port") {
+			// port set explicitly by user -- he/she probably meant it!
+			return newSystemErrorF("Port %d already in use", serverPort)
+		}
 		jww.ERROR.Println("port", serverPort, "already in use, attempting to use an available port")
 		sp, err := helpers.FindAvailablePort()
 		if err != nil {