Git Product home page Git Product logo

Comments (15)

lancerushing avatar lancerushing commented on June 29, 2024 12

I was having the same problem: Putting "go run xxx.go" in the -command doesn't restart.

But after trying a few options, I found the following works:

CompileDaemon -build "go build cmds/server/server.go" -command "./server"

I had to use both the -build and -command flags.

from compiledaemon.

githubnemo avatar githubnemo commented on June 29, 2024 1

OT but since I have done this, config.vm.synced_folder "src/", "/dst", type: 'nfs' should suffice.

from compiledaemon.

githubnemo avatar githubnemo commented on June 29, 2024

Do you have a short example that reproduces the behaviour?

from compiledaemon.

jswierad avatar jswierad commented on June 29, 2024

+1 same here

from compiledaemon.

githubnemo avatar githubnemo commented on June 29, 2024

@jswierad Can you provide a little bit more information? The initial post was not very detailed to begin with so any bit of information helps. What type of application do you run? Can you provide the source code? etc.

from compiledaemon.

jswierad avatar jswierad commented on June 29, 2024

I figured it out already (10 mins ago....)

My issue was vagrant and shared folders. I run my app inside vagrant, with code shared via shared folders (no nfs, no rsync). Changes that I make outside vagrant to this code are not being reported as "modified" inside vagrant, so CopileDaemon doesn't detect any changes.

When I change this code inside vagrant, everything is working correctly.

Now trying to find out how to make my vagrant to use rsync or nfs, since there are some bugs in vagrant in this area as well...

from compiledaemon.

jswierad avatar jswierad commented on June 29, 2024

Thanks a lot for hint; already tried that, unfortunately I'm having issues with vagrant and nfs.
Yak shaving for me today...

from compiledaemon.

jswierad avatar jswierad commented on June 29, 2024

It seems I've found a solution (not perfect, more like workaround, but it works in above setup)

This vagrant plugin: https://github.com/smerrill/vagrant-gatling-rsync
Nice stuff for fixing auto-rsync in Mac and Vagrant that is broken out of the box.

from compiledaemon.

ronaldsuwandi avatar ronaldsuwandi commented on June 29, 2024

@githubnemo I also encountered the same problem

2017/06/21 11:26:05 Running build command!
2017/06/21 11:26:06 Build ok.
2017/06/21 11:26:06 Restarting the given command.
2017/06/21 11:26:11 Running build command!
2017/06/21 11:26:12 Build ok.
2017/06/21 11:26:12 Hard stopping the current process..
2017/06/21 11:26:12 Restarting the given command.
2017/06/21 11:26:12 stdout: 2017/06/21 11:26:12 Error in main(): listen tcp 127.0.0.1:3100: bind: address already in use

Here's the simple example I used to demonstrate the problem

package main

import (
	"log"
	"net/http"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	log.SetOutput(os.Stdout)

	sig := make(chan os.Signal, 1)
	signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL, syscall.SIGQUIT)

	server := &http.Server{
		Addr:    "localhost:3100",
		Handler: http.DefaultServeMux,
	}

	http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
		log.Println("111")
	})

	go func() {
		if err := server.ListenAndServe(); err != nil {
			log.Printf("Error in main(): %v", err)
		}
	}()

	log.Println("interrupt: ", <-sig)
	server.Close()
}

I've tried to include listening to all signals but still didn't work...

I'm running CompileDaemon using the following options
CompileDaemon -verbose -command="go run app.go"

from compiledaemon.

githubnemo avatar githubnemo commented on June 29, 2024

Are you sure that the process is still running or is the socket just not freed yet? Can you check if the process is terminated?

from compiledaemon.

ronaldsuwandi avatar ronaldsuwandi commented on June 29, 2024

I'm not 100% sure. I did grep before/after code change

~/G/s/s/u/r/raw-data ☕️  ps aux | grep app.go
<E> fish: getcwd() failed with errno 2/No such file or directory
rsuwandi         93552   0.1  0.0 556598884   2324 s020  S+    2:50PM   0:00.12 CompileDaemon -verbose -exclude-dir .git -exclude-dir .idea -exclude-dir .vs-code -pattern=(.+\.go|.+\.c|.+\.json)$ -command=go run app.go -color -command-stop
rsuwandi         93638   0.0  0.0  2432804   1952 s027  R+    2:51PM   0:00.00 grep --color=always -I app.go
rsuwandi         93560   0.0  0.1 556633292  11608 s020  S+    2:51PM   0:00.15 go run app.go
~/G/s/s/u/r/raw-data ☕️  ps aux | grep app.go
rsuwandi         93552   0.1  0.0 556598884   2328 s020  S+    2:50PM   0:00.15 CompileDaemon -verbose -exclude-dir .git -exclude-dir .idea -exclude-dir .vs-code -pattern=(.+\.go|.+\.c|.+\.json)$ -command=go run app.go -color -command-stop
rsuwandi         93692   0.0  0.0  2442020   2056 s027  S+    2:51PM   0:00.00 grep --color=always -I app.go
rsuwandi         93682   0.0  0.1 556625356  11676 s020  S+    2:51PM   0:00.17 go run app.go

PID changed so I assume the process is killed but when I call the endpoint it's still responding with the original behaviour (printing "111" instead of something else). If it's only the socket that's not freed I would imagine that hitting the endpoint will not do anything isn't it?

from compiledaemon.

githubnemo avatar githubnemo commented on June 29, 2024

Are you sure that you are running the correct application? It does not seem to be a problem with CompileDaemon as far as I can see.

from compiledaemon.

ronaldsuwandi avatar ronaldsuwandi commented on June 29, 2024

@githubnemo Yup, I recorded a gif file to demonstrate. app.go is the same file as I described earlier

compiledaemon

Previously when hitting the endpoint it prints "111" but I changed it to "abc" and it still shows "111"

from compiledaemon.

ikendoit avatar ikendoit commented on June 29, 2024

@lancerushing Your way worked for me, thanks for sharing!!

from compiledaemon.

githubnemo avatar githubnemo commented on June 29, 2024

To summarize this issue:

  • the general problem of processes not being restarted is fixed with the introduction of hard-stopping, the example in this comment works just fine simply by running CompileDaemon -command ./server, following output can be seen:
% CompileDaemon -command ./server
2020/11/09 22:56:13 Running build command!
2020/11/09 22:56:13 Build ok.
2020/11/09 22:56:13 Restarting the given command.
2020/11/09 22:56:20 Running build command!                         # <- change occured
2020/11/09 22:56:20 Build ok.
2020/11/09 22:56:20 Hard stopping the current process..
2020/11/09 22:56:20 Restarting the given command.
  • with vagrant the issue is that volumes mounted do not seem to propagate the change info properly which makes CompileDaemon think there was no change. This comment suggests to use an rsync plugin with vagrant to sync contents and notify the VM FS about the change.

I think this issue can be closed.

from compiledaemon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.