Skip to content

hugo server should abort if user specified a port and it is taken #1901

@zaichang

Description

@zaichang

If a user runs hugo server and specifies a port, e.g. hugo server --port=55555 currently what it does is assign new port:

ERROR: 2016/02/25 port 55555 already in use, attempting to use an available port

I would argue that if the port is currently in use, hugo should abort instead of assigning a new port, because the user specified the port for a reason. For example it is the port that's exposed in a container or in a shared hosting environment.

In production it is also useful to start a server periodically via crontab in order to automatically restart a server in case of it crashing, and the current behaviour of hugo server results in processes being spawned with every call. It would be nicer if hugo aborts thus allowing the cronjob to restart the server if it dies for any reason.

My current workaround is a script that store a pid file and manages it with start/stop/restart comments as described in this thread.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions