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

修复从软链目录启动laravels后, 更新软链指向路径, reload不生效 #29

Merged
merged 5 commits into from
Apr 18, 2018

Conversation

pauldo
Copy link

@pauldo pauldo commented Apr 18, 2018

线上环境从 php-fpm 模式迁移到 laravels, 遇到上线代码重启不生效问题

fpm部署上线操作:

  1. nginx root 指令指向一个软链目录 /path/to/link_dir, 软链指向 /path/to/version/01;
  2. 上线时, 会创建 /path/to/version/02, 将 /path/to/link_dir 修改指向到 /path/to/version/02;

修改为laravels上线操作问题复现步骤:

  1. nginx root 指令指向一个软链目录 /path/to/link_dir, 指向 /path/to/version/01;
  2. 启动 laravels, php /path/to/link_dir/artisan laravels start;
  3. 查看进程: web 4246 1 0 14:49 ? 00:00:00 /path/to/version/01 laravels: master process;
  4. 上线, 创建 /path/to/version/02, 将 /path/to/link_dir 指向 /path/to/version/02;
  5. 重启 laravels, php /path/to/link_dir/artisan laravels reload;
  6. 修改后的代码不生效, 查看进程仍然是 /path/to/version/01, 无法平滑重启;

@hhxsv5
Copy link
Owner

hhxsv5 commented Apr 18, 2018

👍👍👍Nice!
两点小问题:

  1. laravels_base_path 改名为laravel_base_path,毕竟是Laravel/Lumen项目,默认值修改为env('LARAVEL_BASE_PATH', base_path())
  2. LaravelSCommand中有多处调用了base_path(),这次PR没改全

Copy link
Owner

@hhxsv5 hhxsv5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢参与。

@@ -53,6 +53,7 @@
'reload_async' => true,
'max_wait_time' => 60,
'enable_reuse_port' => true,
'laravels_base_path' => env('LARAVELS_BASE_PATH', ''),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. laravels_base_path改为laravel_base_path
  2. 默认值改修改 env('LARAVEL_BASE_PATH', base_path())

if (empty($svrConf['swoole']['document_root'])) {
$svrConf['swoole']['document_root'] = base_path('public');
$svrConf['swoole']['document_root'] = $basePath ? $basePath . '/public' : base_path('public');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处的三目运算有点多余

@pauldo
Copy link
Author

pauldo commented Apr 18, 2018

Hi, @hhxsv5 1. 名称修改已经 fix; 2. 多处调用 base_path() 如果要修改的话, 可能会对 env() 方法产生耦合, 可以接受吗?

@hhxsv5
Copy link
Owner

hhxsv5 commented Apr 18, 2018

不会依赖env(),只需将base_path()替换成$basePath = config('laravels.laravel_base_path') ?: base_path()

@hhxsv5 hhxsv5 merged commit 26cdd2f into hhxsv5:master Apr 18, 2018
@hhxsv5
Copy link
Owner

hhxsv5 commented Apr 18, 2018

Thanks. laravel_base_path配置读取的位置有点小问题,我改了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants