Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

热更新不可用 #70

Open
ninvfeng opened this issue Mar 7, 2024 · 4 comments
Open

热更新不可用 #70

ninvfeng opened this issue Mar 7, 2024 · 4 comments

Comments

@ninvfeng
Copy link

ninvfeng commented Mar 7, 2024

热更新不可用
php index.php server:watch
Generating optimized autoload files
Generated optimized autoload files containing 1087 classes

Start server ...
PHP Warning: require_once(bin/hyperf.php): Failed to open stream: No such file or directory in /data/docker/fastdeploy/vendor/hyperf/watcher/watcher.php on line 31
PHP Fatal error: Uncaught Error: Failed opening required 'bin/hyperf.php' (include_path='.:/usr/share/php') in /data/docker/fastdeploy/vendor/hyperf/watcher/watcher.php:31
Stack trace:
#0 {main}
thrown in /data/docker/fastdeploy/vendor/hyperf/watcher/watcher.php on line 31
Stop server success.

尝试把 vendor/hyperf/watcher/watcher.php 中的 bin/hyperf.php 修改为index.php后, 能正常启动, 但修改index.php后无法热更新

@devaex
Copy link

devaex commented Jun 25, 2024

I have the same problem.
How do you use hot reload with nano?

@ninvfeng
Copy link
Author

@devaex Now I use nodemon to hot reload
npm install -g nodemon

create nodemon.json file in project

{
    "watch": [
        "index.php"
    ],
    "exec": "php index.php start",
    "signal": "SIGINT"
}

then run nodemon

@devaex
Copy link

devaex commented Jun 26, 2024

Thanks. This worked.

As a suggestion, the watcher should be included in nano.
It is something very basic and essential for development.

As it has a dependency on bin/hyperf.php there is no way to use it outside of the main framework.

@devaex
Copy link

devaex commented Jun 26, 2024

Another solution that does not depend on node.

#!/bin/bash

exitfn () {
  kill $PID    
  echo; echo "Exiting and killing process $PID"
  exit
}

# to handle ctrl+c for forced finalization
trap "exitfn" INT   

while true
do
    php app/server.php start & PID=$!
    echo "Process cretated: $PID"
    inotifywait -e modify,create,delete -r ./app
    echo "Killing process $PID"    
    kill $PID
done

sudo apt install inotify-tools to install inotify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants