I am facing a weird issue on windows machine. I am using php-cgi and nginx to run my php project. Everything works fine for a specific period of time like for example 15 to 20 hours then php-cgi and nginx both services stopped working. This happens repeatedly when I start the services again. Please check below is my bat file content.
Bat file content:
#ECHO OFF
ECHO Starting PHP FastCGI...
SET PHP_FCGI_MAX_REQUESTS=0
start C:\webserver\nginx\nginx.exe
C:\RunHiddenConsole.exe C:\webserver\php\php-cgi.exe -b 127.0.0.1:9000 -c "C:\werbserver\php.ini"
Related
We are having a Docker server 'Docker version 17.03.0-ce, build 60ccb22'. We have a number of workers, around 10,each one of them performs a really simple task that takes a few seconds to complete and exit. We decided that every one of them is going to start a docker container and when the script finishes, the container gets stopped and removed. What is more, crontabs deal with running So, we created a bash script for every worker that instantiates the container with the flags --rm and -d and also starts the script file in the bin/ folder
#! /bin/sh
f=`basename $0`
workerName=${f%.*} \\name of the bash script without the part after the .
//We link with the Docker host the folder of the worker and a log file that is going to be used for monitoring from outside the container.
docker run --rm -d --name $workerName -v `cat /mnt/volume-fra1-05/apps/pd-executioner/master/active_version`:/var/www/html -v /mnt/volume-fra1-06/apps/$workerName.log:/var/www/html/logs/$workerName.log iqucom/php-daemon-container php bin/$workerName
echo `date` $0 >> /var/log/crontab.log
So, we created a bash script for every worker that instantiates the container with the flags --rm and -d and also starts the script file in the bin/ folder. All the workers are very similar to the structure and the code and really simple, there are not big code differences. However, we have experienced the following behaviour: some containers (random ones every time) refuse to stop and be removed even after many hours. Inside the container, the process php bin/$workerName is still running with PID 1. There is nothing like an infinite loop in the code that could stop the script from finishing. It happens randomly and still cannot find a pattern. Do you have any idea on why this might be happening?
So this can be some issue related to your PHP script getting stuck somehow. But since you are sure it is suppose to timeout after lets assume 240secs then you should can change your container command to
docker run --rm -d --name $workerName -v cat /mnt/volume-fra1-05/apps/pd-executioner/master/active_version:/var/www/html -v /mnt/volume-fra1-06/apps/$workerName.log:/var/www/html/logs/$workerName.log iqucom/php-daemon-container timeout 240 php bin/$workerName
This will make sure that any stuck container will exit after a timeout if it doesn't exit on its own
One of the solutions I found is this:
check process php5-fpm with pidfile /var/run/php5-fpm.pid
group php
start program = "/etc/init.d/php5-fpm start"
stop program = "/etc/init.d/php5-fpm stop"
if failed unixsocket /tmp/php-fpm.sock then restart
if 4 restarts within 5 cycles then timeout
depends on nginx
This does not work because the following file does not exist in my system:
/tmp/php-fpm.sock
When I run sudo find / -name *.sock I get:
/run/mysqld/mysqld.sock
/run/fail2ban/fail2ban.sock
/var/lib/php5-fpm/web2.sock
/var/lib/php5-fpm/ispconfig.sock
/var/lib/php5-fpm/apps.sock
If it helps, this is the file I change to configure how php behaves with the particular domain I use : /etc/php5/fpm/pool.d/web2.conf. So MAYBE the right file is `/var/lib/php5-fpm/web2.sock ?
This is a VPS with ubuntu 12.04 and nginx 1.4.4.
I have a php script. I am using nginx and spawn-fcgi.
spawn-fcgi -n -s /tmp/nginx9010.socket -u www-data -g www-data -f /usr/bin/php5-cgi -C 6
How can I test from the command line that spawn-fcgi is working with the script?
e.g. I have a script in /home/ubuntu/test.php
I am having issues with nginx and executing a php script. It prompts for a download.
I have #!/usr/bin/php in the file and did a chmod a+x as well.
Thanks
For testing a FastCGI backend you could try to create a CGI environment and use cgi-fcgi to connect to the backend
You could attach with strace to see what the backend does (for example whether it even receives a request from the web server); attach with -ff to the master process to see syscalls on all workers
php5-cgi in FastCGI mode doesn't need a shebang line nor +x on the files - it doesn't use the kernel to execute them, it just loads them as simple files
Firefox (and probably other browsers too) often cache the mime type, so you will see a download prompt even after you fixed the problem. Use curl for testing!
nginx won't serve the file it passes it to php, nginx only serves static files, So if it is downloading the php file you might need to check that your are sending php files to the correct place, are you using an IP and PORT in the php location block in the config file ?
Only a guess of the top of my head whilst on the train home.
FWIW, problems like that nginx offers the file to be downloaded are due Nginx serving the files itself without sending them to fastcgi backend, often because of try_files or wrong location {} block matching to the uri.
I want testing my site load (site is write on php) via apache bench.
I have local server (xampp), OC: windows.
In directory apache/bench there is file ab.exe, this means that apachebench is installed in my local server yes?
I have local site localhost/my_test, I want simulate concurrent 1000 request on this site, in CMD I write this command:
ab -c 1000 localhost/my_test
answer from CMD is: 'ab' is not recognized as an internal or external command,
operable program or batch file.
Tell please, where I wrong?
AB needs a complete URL:
Usage: ab [options] [http://]hostname[:port]/path
So, in your case the URL should look like:
localhost/my_test/
It needs the path - which in this case is simply the /
Hope this helps
Paul.
ab -c 1000 localhost/my_test
answer from CMD is: 'ab' is not recognized as an internal or external command, operable program or batch file.
It means that ab.exe not in your PATH.
If you start CMD, first you should navigate yourself into the apache/bench directory, and run the command from that folder.
I think you should type your port that your server has been running on;
For example, I use http://127.0.0.1:8080 (port is 8080 as I set in my XAMPP config)
I have XAMPP installed on Windows 7. I need to stop and start Apache many times every day.
Currently, I do this by opening up the Xampp control panel, clicking 'Stop' (next to 'Apache'), waiting for it to stop, then clicking 'Start'.
Ideally I would like to be able to do this more quickly - something like right click the Xampp icon, and choosing 'Restart Apache'. Or, even better, just a shortcut key that restarts Apache.
I know that there are two bat files with Xampp - apache_stop.bat and apache_start.bat. I've tried utilising these to get want I want. However, when you run apache_start.bat, you get a cmd window that you can't get rid of. I couldn't find a way to start Apache silently in this way.
So, basically I want to be able to quickly restart Apache (one click/shortcut key), completely silently.
Thanks in advance.
Copy apache_start.bat and rename it to apache_restart.bat.
Change the line apache\bin\httpd.exe to apache\bin\httpd.exe -k restart
Voila, there you go with your restart script.
and you can also give it a shortcut.
If you have the Apache service monitor in your system tray, you can just open that (right click, I think?) and click "restart Apache".
If it's not in your system tray, you can find it in the /bin folder of the Apache installation (called ApacheMonitor.exe). I'd recommend making a shortcut to it in the "Startup" folder.
For me, with the version 3.2.2 the first answer didn't work.
I've put together a script from the two apache_start.bat and apache_stop.bat files.
#echo off
cd /D %~dp0
echo Apache 2 is stopping...
apache\bin\pv -f -k httpd.exe -q
if not exist apache\logs\httpd.pid GOTO exit
del apache\logs\httpd.pid
echo Apache 2 is re-starting ...
apache\bin\httpd.exe
if errorlevel 255 goto finish
if errorlevel 1 goto error
goto finish
:error
echo.
echo Apache konnte nicht gestartet werden
echo Apache could not be started
pause
:finish
#adrianthedev's version didn't work for (XAMPP v3.2.4) me but helped me find a solution.
It's a lot less sophisticated as I don't know much about scripting but here it is and it worked for me:
#echo off
C:/xampp/apache/bin/httpd -k stop
C:/xampp/apache/bin/httpd -k start
Note: apache\logs\httpd.pid doesn't need to be deleted as it's done already by the httpd -k stop command.