Socket-activate development server (maybe via systemd)?

Hi,

is it possible to socket-activate the development server via systemd so that you would not have to start it manually, but rather it gets started automatically whenever a page is requested from port 1313?

I have tried to make it work via user-units and I can make it start automatically whenever I access port 1313 but currently my problem is that the dev-server sees port 1313 as being taken by systemd and so starts on a random port, thereby defeating the purpose of the exercise a bit…

So is there a way to make a development server automatically start on port 1313 whenever this port is accessed?

Many thanks!

no.

but you can start the dev server on system start and control if it’s still running. your current problem is because an old or zombie hugo server is still running. kill -9 hugo and re-test. It however depends on your operating system and how you start services and how the firewall on your system works. not really a hugo question and on https://serverfault.com/ might be the better place (stack exchange for servers) to ask.

“No” is simply wrong.

It is possible, though you need a more sophisticated approach as I have tried in the beginning.

And the problem with my old approach is not a “zombie hugo server” but as I described above it’s systemd listening on port 1313 (I had a systemd socket-unit to tigger a service-unit) and then when hugo is started it finds the port taken and then seems to bind to a random port (not sure if this behaviour is documented but this is what I see). The log messages show this:

Jun 26 23:15:25 kyrth systemd[1403]: Started Hugo Dev Server Service.
Jun 26 23:15:25 kyrth hugo[97078]: port 1313 already in use, attempting to use an available port

Jun 26 23:15:25 kyrth hugo[97078]: Web Server is available at http://localhost:36513/ (bind address 127.0.0.1)

I don’t quite understand why you make wild guesses without even knowing or understanding what I tried…

I don’t quite understand why you make wild guesses without even knowing or understanding what I tried…

Ok, won’t use my brain for your problems anymore. More resources for real Hugo related issues.