puma / puma-dev

A tool to manage rack apps in development with puma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running puma-dev in background will not pickup changes to file after restart.

jgervin opened this issue · comments

Running Puma-dev on my MAC osx 10.13.4 and puma-dev will not recognize file changes.

I am forcing puma closed via

puma-dev -stop
AND
pkill -USR1 puma-dev

I restart with "puma-dev" and the changed files are not recognized.

I'm using Mac OS 10.15. Changed some config files on my Rails app, and tried touch tmp/restart.txt but puma-dev doesn't restart to take effect of the changes. Had to puma-dev -stop then reload my app to see the changes.

I have same issue after my mac upgraded to 10.15.

I have same issue. Only puma-dev -stop will refresh rails env configuration

I just upgraded to macOS 10.15.2 yesterday and am experiencing the same issue. Previous version was 10.14.x.

I'm also seeing this, and happy to do some debugging if someone can point me in the right direction to look. Neither puma-dev.log or the /events json gain any lines when I touch tmp/restart.txt.

I have a SWAG suspicion that this is related to the outdated fsevents library present in the current Homebrew release. It's been updated on master.

Do you mind trying to install from source and see if that resolves the issue? You'll find instructions in the readme.

@nonrational I ran launchctl unload <plist> and then brew uninstall puma-dev, and then make in a fresh checkout of puma-dev at 69b5794. ps shows it running out of the checkout directory, and unfortunately... still nothing in either the log or event list when I touch tmp/restart.txt. (The app doesn't restart, either.)

@indirect I'm able to exercise the touch restart.txt behavior with a simple rack app served via foregrounded puma-dev. It's a bit hard to watch the inner workings once it's daemonized. There are definitely some improvements to be made to logging and traceability.

Would you mind trying to reproduce with your rails app with puma-dev in the foreground?

Results

# macOS 10.14.6
$ ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
$ puma --version
puma version 4.3.1

I added an else condition to the kill function to ensure that I'm not actually hitting the error case. That's why you see the "! Killed ..." messages above.

diff --git a/dev/app.go b/dev/app.go
index dbf3443..cdf4858 100644
--- a/dev/app.go
+++ b/dev/app.go
@@ -96,7 +96,10 @@ func (a *App) Kill(reason string) error {
                        "error", err.Error(),
                )
                fmt.Printf("! Error trying to kill %s: %s", a.Name, err)
+       } else {
+               fmt.Printf("! Killed '%s' (%d)\n", a.Name, a.Command.Process.Pid)
        }
+
        return err
 }

Here's my rack app. It's in a folder called rack-hi-puma that's symlinked into ~/.puma-dev

class Application
  def call(env)
    status  = 200
    headers = { "Content-Type" => "text/html" }
    body    = ["Hi Puma!"]

    [status, headers, body]
  end
end

run Application.new

@nonrational well, as far as I can tell, I am exactly copying your methods, but with sadder results. Please let me know if you see anything I could try doing differently!

puma-dev-restart

EDIT: Tests are failing. So, if you are interested, I'd still hold off.

I added some tests to the watch package to investigate this behavior. If you're interested in running these tests on your 10.15 machine (🙏), please pull the latest from master.

@nonrational hell if I know what's going on here 😬

❯ git sha
c64713752f0c0d4a7a8fae51ba28a5e57f348da1
❯ go test -v -count=1 -timeout=10s -test.run=TestWatch ./...
go: downloading github.com/fsnotify/fsevents v0.1.1
go: downloading github.com/miekg/dns v0.0.0-20160726032027-db96a2b759cd
go: downloading github.com/bmizerany/pat v0.0.0-20160217103242-c068ca2f0aac
go: downloading github.com/hashicorp/golang-lru v0.0.0-20160207214719-a0d98a5f2880
go: downloading gopkg.in/tomb.v2 v2.0.0-20140626144623-14b3d72120e8
go: downloading github.com/kardianos/osext v0.0.0-20151222153229-29ae4ffbc9a6
go: extracting github.com/fsnotify/fsevents v0.1.1
go: downloading github.com/vektra/errors v0.0.0-20140903201135-c64d83aba85a
go: downloading github.com/stretchr/testify v1.3.0
go: downloading github.com/vektra/neko v0.0.0-20141017182438-843f5ecf6932
go: extracting github.com/vektra/neko v0.0.0-20141017182438-843f5ecf6932
go: extracting github.com/stretchr/testify v1.3.0
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/stretchr/objx v0.2.0
go: extracting github.com/davecgh/go-spew v1.1.1
go: extracting github.com/pmezard/go-difflib v1.0.0
go: extracting github.com/stretchr/objx v0.2.0
go: extracting github.com/bmizerany/pat v0.0.0-20160217103242-c068ca2f0aac
go: extracting gopkg.in/tomb.v2 v2.0.0-20140626144623-14b3d72120e8
go: extracting github.com/kardianos/osext v0.0.0-20151222153229-29ae4ffbc9a6
go: extracting github.com/hashicorp/golang-lru v0.0.0-20160207214719-a0d98a5f2880
go: extracting github.com/vektra/errors v0.0.0-20140903201135-c64d83aba85a
go: extracting github.com/miekg/dns v0.0.0-20160726032027-db96a2b759cd
go: finding github.com/fsnotify/fsevents v0.1.1
go: finding github.com/stretchr/testify v1.3.0
go: finding github.com/vektra/errors v0.0.0-20140903201135-c64d83aba85a
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/bmizerany/pat v0.0.0-20160217103242-c068ca2f0aac
go: finding github.com/hashicorp/golang-lru v0.0.0-20160207214719-a0d98a5f2880
go: finding github.com/kardianos/osext v0.0.0-20151222153229-29ae4ffbc9a6
go: finding github.com/miekg/dns v0.0.0-20160726032027-db96a2b759cd
go: finding gopkg.in/tomb.v2 v2.0.0-20140626144623-14b3d72120e8
go: finding github.com/vektra/neko v0.0.0-20141017182438-843f5ecf6932
go: finding github.com/stretchr/objx v0.2.0
testing: warning: no tests to run
PASS
ok      github.com/puma/puma-dev/cmd/puma-dev   0.431s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/puma/puma-dev/dev    0.293s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/puma/puma-dev/dev/devtest    0.160s [no tests to run]
?       github.com/puma/puma-dev/dev/launch     [no test files]
?       github.com/puma/puma-dev/homedir        [no test files]
?       github.com/puma/puma-dev/httpu  [no test files]
testing: warning: no tests to run
PASS
ok      github.com/puma/puma-dev/httpu/internal 0.107s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/puma/puma-dev/httputil       0.196s [no tests to run]
testing: warning: no tests to run
PASS
ok      github.com/puma/puma-dev/linebuffer     0.249s [no tests to run]
=== RUN   TestWatch_ExpectTimeout
--- PASS: TestWatch_ExpectTimeout (2.01s)
=== RUN   TestWatch_ExpectTouchSignalAfterModify
--- PASS: TestWatch_ExpectTouchSignalAfterModify (1.03s)
PASS
ok      github.com/puma/puma-dev/watch  3.209s

So everything seems to pass? And yet after rebuilding from master, neither touch tmp/restart.txt or rm tmp/restart.txt produce any output at all from puma-dev -debug. :/

well, every bit of information helps! 🤷‍♂i have machine i can upgrade to 10.15 and see if i can replicate.

"good" news: i can now replicate the problem on a mbp running 10.15. 🙃

interestingly, fsnotify/fsevents@f721bd2 tests fail on this machine too -- they timeout. but, the puma-dev watch_test.go tests pass...

@indirect try building from watch-unwrap-symlinks and let me know how it goes! 🤞

@nonrational good news and bad news! I built from the watch-unwrap-symlinks branch, and... it doesn't work. But if I copy the rack app to live directly inside ~/.puma-dev/rack-hi-puma... it does work. So something about the symlink unwrapping must not be working still? I guess?

@indirect do you mind pulling latest from that branch and trying again? specifically, let me know what values you see for the two lines highlighted in green and red below. i just added prints around the call to filepath.EvalSymlinks

@nonrational 😮😮😮 it works! you are a wizard. 🧙‍♂️

maybe I somehow still had a previous build in memory the previous time, I don't know. thank you so much for fixing this!!!