Automatic restart service

Swoft 2.0 removes the auto-restart feature from the built-in components and is provided by the new standalone tool swowt-cli. Help developers make the changed code take effect quickly during development.

It should be noted that 2.0 is to restart the entire service instead of reloading the work process like 1.0.

Command: serve:run (you can also use the alias run directly)

View available options

 php swoftcli.phar run -h

# 如果已放到了全局PATH里,可以直接这样使用
swoftcli run -h 

Hot-restart-help

Option list

  • -b, --bin-file --bin -b, --bin-file specifies the entry -b, --bin-file for the swowt application. The default is bin/swoft
  • --interval monitor file interval, check by default 3 seconds
  • --php-bin specifies your php executable file. By default, it will automatically find php from the global path.
  • -c, --start-cmd specifies the server startup command. The default is http:start (start http server)
  • -w, --watch specifies the directory to monitor, relative to the application directory. Default monitoring app,config file changes in app,config

parameter list

targetPath only one parameter, which specifies the directory where the swowt application to be run is located. The default is the current directory.

Use example

 swoftcli run -c ws:start -b bin/swoft /path/to/php/swoft 

After running successfully, you can see the following information:

Run-hot-restart

Swoft-cli will automatically restart the app when there is a file change.

Warning ⚠️ When using Swoftcli to monitor server development, you cannot configure the server to run in the background. Otherwise, Swoftcli will mistakenly think that the server has quit unexpectedly, resulting in repeated startup.

/docs/2.x/en/tool/swoftcli/hot-restart.html
progress-bar