简体   繁体   English

Laravel 4 Mail :: queue没有使用正确的环境

[英]Laravel 4 Mail::queue not using the right environment

I've been working on this website for a while and just recently finished and wanted to "go live". 我已经在这个网站上工作了一段时间,最近才完成,想“上线”。 I have two environments in my production server: staging and production. 生产服务器中有两个环境:暂存和生产。 Both environments seem to work fine, each of them with their own configurations. 两种环境似乎都可以正常工作,每种环境都有自己的配置。

The weird problem I'm facing is when sending an email using Mail::queue, the views that are being picked up by the mail class are the ones in the staging environment and not the ones in production, which also seems to make the class think that it's in the staging environment. 我面临的怪异问题是在使用Mail :: queue发送电子邮件时,mail类所选择的视图是登台环境中的视图,而不是生产环境中的视图,这似乎也使该类成为了此类认为它处于暂存环境中。 So all the URL's in the received email (all configured in the view to be like URL::to('route')) point to the staging environment instead of production. 因此,收到的电子邮件中的所有URL(都在视图中配置为类似于URL :: to('route'))都指向暂存环境,而不是生产环境。 So if staging is like staging.domain.com and production www.domain.com, the links in my emails sent from the production environment are staging.domain.com (the contrary doesn't happen) 因此,如果登台类似于staging.domain.com和生产www.domain.com,则从生产环境发送的我的电子邮件中的链接就是staging.domain.com(相反不会发生)

This does not occur with the rest of the links in the website, only with emails. 网站上的其他链接不会发生这种情况,只有电子邮件会发生这种情况。

I haven't been able to figure this one out, and I was hoping someone around here can help me out! 我还没弄清楚这一点,我希望周围的人能帮助我!

Thanks! 谢谢!

PS: I've already tried clearing out the views in the storage folder, the cache using artisan cache:clear PS:我已经尝试使用artisan cache:clear清除存储文件夹(即缓存)中的视图

Since there is no HTTP request associated with queued jobs, they must get the application url from a config setting. 由于没有与排队作业关联的HTTP请求,因此它们必须从配置设置中获取应用程序URL。 This config setting is the url key in the app.php configuration file. 此配置设置是app.php配置文件中的url键。

My guess is that you have set the url key in the app/config/app.php file to staging.domain.com . 我的猜测是您已将app/config/app.php文件中的url密钥设置为staging.domain.com

You can override configuration files per environment by creating a subdirectory in the app/config directory with the environment name. 您可以通过在app/config目录中使用环境名称创建子目录来覆盖每个环境的配置文件。 I prefer to leave the php files in the app/config directory alone, and make any config changes to environment specific config files. 我更喜欢将php文件放在app/config目录中,而对环境特定的配置文件进行任何配置更改。

As an example, one solution to your problem would be to create the following files (assuming your environment names are "staging" and "production"): 例如,解决您的问题的一种方法是创建以下文件(假设您的环境名称是“ staging”和“ production”):

app/config/staging/app.php app / config / staging / app.php

return array(
    'url' => 'http://staging.domain.com',
);

app/config/production/app.php app / config / production / app.php

return array(
    'url' => 'http://www.domain.com',
);

You can read more about environment configuration here . 您可以在此处阅读有关环境配置的更多信息。

The problem was related to the supervisord configuration. 问题与监督配置有关。 Basically there was only one queue and it was the staging one. 基本上只有一个队列,这是分段队列。

Resolved the issue by updating the supervisord.conf with the production queue info. 通过使用生产队列信息更新supervisor.conf解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM