- Notifications
You must be signed in to change notification settings - Fork3.2k
-
I am running a swoole http server and trying to figure out how reloading works. Is there a complete example somewhere of how hot reloading works? I'm used to php-fpm where I can edit any file and refresh in my browser to see the changes, and I'm trying to figure out how close I can get to simulating that with swoole. Thanks for your help. Ryan |
BetaWas this translation helpful?Give feedback.
All reactions
Maybe try something like:
$this->server = new Swoole\Http\Server("127.0.0.1", 9501, SWOOLE_BASE);
$this->server->set([
... other options here ...
'worker_num' => 2, // The number of worker processes to start
]);
If that does not work, try:
$this->server = new Swoole\Http\Server("127.0.0.1", 9501, SWOOLE_PROCESS);
$this->server->set([
... other options here ...
'worker_num' => 2, // The number of worker processes to start
]);
Replies: 3 comments 3 replies
-
I think you may be able to use this bash script: https://gist.github.com/lotharthesavior/4c3aa47665d83a0d4fbdd293ac11f7cc |
BetaWas this translation helpful?Give feedback.
All reactions
-
This may also be usable: |
BetaWas this translation helpful?Give feedback.
All reactions
-
@henrywood: thanks, I tried with the example server.php onhttps://github.com/skoro/slim-swoole-integration. I had to edit one line in HotCodeReloader.php to have it work: old: new: After I did that and edited server.php, I got this error:
Does server.php need to be structured differently for it to work? Thanks. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Maybe try something like: $this->server = new Swoole\Http\Server("127.0.0.1", 9501, SWOOLE_BASE); $this->server->set([ If that does not work, try: $this->server = new Swoole\Http\Server("127.0.0.1", 9501, SWOOLE_PROCESS); $this->server->set([ |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks, it seems to work with SWOOLE_PROCESS. With SWOOLE_BASE, I started getting these errors when I edited a file:
I may have more questions, but I will first try out some more complex examples with SWOOLE_PROCESS. Thanks again for your help. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I have one other question I was hoping to get help with: I'm now looking at implementing a Coroutine HTTP Server. Onhttps://wiki.swoole.com/en/#/server/co_init, it says:
Do you have an example of how reloading can be done in a coroutine? Would I pass $reuse_port=true to my original coroutinue, and then create another coroutinue when I want to reload, and then shutdown my original coroutine? Would that do it in a graceful way to not interrupt any connections? Or is there a different way to structure it? Thanks for your help. |
BetaWas this translation helpful?Give feedback.