方案思路:
- 把php应用部署到openresty + PHP(FPM)
- 通过openresty的 init_worker_by_lua_block特性,在第一个worker被创建时,读取服务配置文件
- 把服务配置文件中的信息通过eureka或者consul的rest api,注册服务实例
- 如果是eureka,启动timer定时刷新心跳
- 当nginx被优雅关闭时(nginx -s quit), 主动注销服务实例
项目代码:
https://github.com/tangaiyun/SpringCloudOpenrestyPHP