I am currently working on the project that has over 20 cron jobs. Some of them are pretty long processes. It was built on Symfony 2.8, so we decided to upgrade it to 3.4 LTS.
After the upgrade we noticed that, if there is ongoing cron job (long process) and we push some changes to Prod environment we get this error:
Fatal Compile Error: require(): Failed opening required '/.../cache/prod/
Turns out, that when we deploy the changes, cached container (in var/cache/prod/ContainerXXXXXX) changed the XXXXXX value. Or in other words, we clear the cache (during deploy) and then it generates new Container in cache directory. More about this problem: https://github.com/symfony/symfony/issues/25654 .
So, my question (and idea) is, is it possible to make cache Container directory name always the same? Maybe any ideas how?
Related
I am currently working on the project that has over 20 crons. Some of them are pretty long processes. It was built on Symfony 2.8, so we decided to upgrade it to 3.4 LTS.
After the upgrade we noticed that, if there is ongoing cron job (long process) and we push some changes to Prod environment we get this error:
Fatal Compile Error: require(): Failed opening required '/.../cache/prod/
Turns out, that when we deploy the changes, cached container (in var/cache/prod/ContainerXXXXXX) changed the XXXXXX value. Or in other words, we clear the cache (during deploy) and then it generates new Container in cache directory. More about this problem: https://github.com/symfony/symfony/issues/25654 .
So, I came up with the idea, add a script with a while loop (?) which checks if there is any running crons, if not run the deploy.
But the question is, is there a way to check this in current situation?
There are many ways to achieve this. Just any kind of semaphore (a file, a database record) to store the "running" status and have the same process clear it when it's done.
Any deployment job should check the value of this semaphore before continuing. A simple flat file would be easiest, since you may not have access to more sophisticated features during deployment, but reading a text file should be easy no matter what kind of of deployment process you are using.
Last week, I tried to deploy a simple symfony app on azure.
I choose the plan app service B2 (2cores / 3.5Go RAM).
PHP Version : 5.6.
First it took forever to complete the composer install. (I tried to go on S3, it was a little faster but not very different).
So I tried to optimize the php config, opcache, realpath_cache_size...etc (xdebug already disabled).
I even tried to enable wincache, but with no real improvment.
So now my app is deployed, but it is too slow to be usable.
A simple php app/console (in dev mode) takes ~23secondes.
It seems to recreate the cache everytime. On my local unix environnment (similar specs), it takes 6seconds when the cache is cold and 500ms when the dev cache is warm.
I think that the main problem is a filesystem issue, because to remove the dev cache folder it takes 16 seconds.
On my local unix environnment, similar specs, it takes ~200ms to remove the same folder.
Like I said I tried S3 Plan with a small improvment but not enough to explain this slowness.
One thing weird, it's that if I rerun the command php app/console just after it finished, the command takes 5seconds to run (much better). But If rerun it 5seconds after it finished, it takes 23seconds.
I already tried these solutions (even if the environnment is different) :
https://stackoverflow.com/a/17021255/6309878
Update : I tried to set the symfony app/cache folder to the local filesystem D:\local\cache, but no improvment, it may be worst.
Please try below steps and let me know if it improves the performance -
1) In the wwwroot directory of your site, create a .user.ini file (if it doesn’t already exist) and add “wincache.fcenabled=0”. This will disable Wincache.
2) Go to Azure Portal and go to the Application Settings for your app. In the App Settings section, add “WEBSITES_DYNAMIC_CACHE” with a value of 1.
3) Restart the site.
i'm using github in combination with laraval for the first time.
I have 2 local environments :
a) i use MAMP Pro for local development (Mac)
b) i use XAMPP for local development (Windows)
I made a new repository and pushed to github on environment a) , I cloned this repository on setup b) and added a .env file to setup my database. However i'm a bit confused what to do with the app_key value, do i need to just copy it form my initial environment? or need a new one?.
The second part of my question is that i seem to have problems with xampp vs mamp pro because they rewrite a couple of urls, wich means my project won't run on environment b). Are there other settings i need to adjust? and will it brake again if i commit on environment b) ?
Error message when running the project on environment b)
Warning: require(D:\dev.local\ADifferentDesign\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in D:\dev.local\ADifferentDesign\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required 'D:\dev.local\ADifferentDesign\bootstrap/../vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in D:\dev.local\ADifferentDesign\bootstrap\autoload.p
I'm really confused , i saw other questions like this but none are quite what i was looking for.
A good aproach for future projects would also be very much appreciated
Progress update 1: I updated my .env file with the same key. But the error shown above still persists. I dont want to change te path in autoload every time i switch environments either.
It depends. If you are sharing any resources that hold encrypted data between the two environments, like a database, then you must copy the app_key. This is because Laravel uses the app_key whenever it encrypts something like a user's password or a session ID.
If you don't need to share a database, sessions, etc then you can and should generate a new key for every environment.
You generate a new key by running this command in your site root:
php artisan key:generate
Ideally, you would run this command as the first step in setting up a new environment, before running database seeds or other stuff. This is because if you generate a new key after seeding your database then any password you created in the seeds will be invalid and you'll have to reseed the database.
I'm not allowed to install Composer on my server at work. Bureaucracy! Also, it's not connected to the internet. It's a company intranet server and I'm not a sys admin for it.
Am I going to experience high levels of difficulty installing and running Laravel without Composer? Should I use another Framework?
I'm quite a basic PHP programmer without too much command line experience to be honest. I'm used to having everything I need for a project contained in one directory - like CodeIgniter for example.
This article is suggesting that there are quite a few required dependencies. Will my Laravel project just fail to run properly without them?
-- UPDATE --
If by chance, there is a way to do it without Composer, then please tell me how I can do this. I downloaded the source files for Laravel from GitHub (like you would do with CodeIgniter) but I get errors when I try and view it on a browser;
Warning: require(/var/www/html/test/laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/test/laravel/bootstrap/autoload.php on line 17
Fatal error: require(): Failed opening required '/var/www/html/test/laravel/bootstrap/../vendor/autoload.php' (include_path='.:/php/includes:/var/www/html/php/includes:/jpa/release/jpa/includes:/usr/share/pear:/usr/share/php/phpmailer:/apache/htdocs/applications/surveys/Includes:/var/lib/ZF1/library') in /var/www/html/test/laravel/bootstrap/autoload.php on line 17
I guess one way would be to run composer on another machine(maybe at home). Then just take all the files that composer downloads and move it to your work machine.
Installing it manually is a lot of work. You have to do all the stuff that composer does in the background effectively. Following all the dependencies will be super hard.
I'm using LAMP with CodeIgniter for one of my projects; version controlled by SVN. Every time I execute svn export file:///svnrepo/project/trunk/www . --force when in the www directory and then reload the web page, it goes blank.
The website only shows up after I do a service httpd restart (Using CentOS 5).
I want to be able to execute the svn export using a Phing build script in the future and I don't want to have to get root privileges and restart apache every time when I do a build.
Is what I'm experience a common problem? How do I solve it without restarting apache?
Edit:
It seems someone has had this problem before: http://codeigniter.com/forums/viewthread/181642/
Ok I got it.SVN maintains a files last modified time which throws off the APC cache. So to solve it we update the last modified time of all the files after we run an SVN export. Here is my final script:
#!/bin/sh
svn export --force file:///home/steve/repo/exmaple/trunk \
/home/steve/public_html/example.com/public/
find /home/steve/public_html/exmaple.com/public | xargs touch
You can find more details here.
An alternative solution would be to set apc.stat=0 (reference) in the apc.ini, and then use apc_clear_cache() (reference) to force the removal of the opcode cache.
What's awesome about this solution is that when apc.stat is set to 0, it disables the check on each request to determine if the file has been modified. This results in a huge performance boost.
Additionally, using apc_clear_cache() to clear the APC cache tends to result in a cleaner build. I've run into wonky race conditions where certain files will get built out that have dependencies on others that have not yet been built out. This results in a spat of FATAL errors. The only caveat here is that apc_clear_cache() needs to be run via apache, so you'll need to implement a wgetor something similar for this.