I use echo framework for creation of my API server. It is started by systemd and needs root by default, in order to aquire ports below 1024. For security I like to downgrade privileges of my go program after the listening port has been aquired by echo framework.
I know how to downgrade, but I can not find a suitable event/callback for this? The problem is, that echo.Start()
and echo.StartAutoTLS()
do not come back. I can create a parallel thread and try to find some status value of my echo session telling me that the port was opened, but I can not find such status indication either.
How can I make sure that I get some code executed after the port is aquired (and know for sure)?
Until now I run a parallel go thread just before server creation and wait 5 seconds to do the downgrade then. It works so far, but this is hacky and I don't like it :-(