문제

I'm trying out Martini, which adds some nice functionality upon Go's basic net/http package.

I was wondering tho. How can I, like Django does too, let the server restart itself on source-file changes? I know how to monitor a file, but I'm not sure how to retrigger the Server within the same process.

I'm guessing to trigger http.ListenAndServe again, but I have a feeling it doesn't go well with instance already running.

Do I need to spawn a subprocess/daemon to get this working?

도움이 되었습니까?

해결책

Maybe you need gin ?

Made by the creator of Martini.

다른 팁

You may give it a try

Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file.

You'll need to use an external tool that can watch a directory/files and run a command. I'd recommend reflex which is written in Go itself:

(modifying the example in the README):

# Rerun make whenever a .go file changes
reflex -r '\.go$' ./mymartiniapp
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top