Restart apache forcing it - apache

I have a Centos server running Apache and sometimes the server is working fine but I need to restart it due to changes in Apache configuration files. I usually execute:
systemctl restart httpd.service
But sometimes this command hangs for 4 or 5 minutes! It takes very long to stop apache. I know the problem is stopping and not starting cause if I execute systemctl stop httpd.service it also takes 4 or 5 minutes.
Is there anyway to force apache to restart without waiting so long?

I found that reload option is better than restart httpd service.
systemctl restart httpd

Related

redis start with /usr/bin/redis-server fine but stop on systemd start

I have install redis on centos 8 and everything works fine but after I have reboot the server, redis top working, I have try to start by systemctl start redis but service start and stop unexpectedly
I have try /usr/bin/redis-server /etc/redis.conf and service start successfully but still got following error on starting bye systemctl
redis.service: Failed with result 'exit-code'
can anybody help me about this?
-----edit-------
I have check /var/logs/redis/redis.log and found that se linux cause the problme
I have try setenforce permissive and now redis working fine.
but why this happend?
I didn`t change anything about SELinux and suddenly the error occurred

Redis don't stop or restart on CentOS7

I've installed Redis version 3.2.12 on one node CentOS 7 of a cluster with Cloudera Manager 6.3 and my redis never stop.
Everything is on default, I just added the password, but that has no effects because I can't restart. Option daemonize is no
My instalation was:
sudo yum -y install redis
sudo service redis start
When I type redis-cli, CLI starts normally at 127.0.0.1:6379. When I try shutdown, the console shows 'not connected', but with lsof -i :6379 I can identify that some jobs die and return with another PID.
If I try to kill the redis jobs, it always return with another PID.
service redis stop Return 'Redirecting to /bin/systemctl stop redis.service' but has no effects.
If I try service redis restart then service redis status it returns:
redis.service: main process exited, code=exited, status=1/FAILURE
Unit redis.service entered failed state.
Someone can please help me as a way to debug or understand what is happening? It's my first time with Redis.
Not sure how is this related to celery...
CentOS 7 uses systemd so I would recommend stop using the service tool and start using the systemctl. First thing you should try is systemctl status redis to check the status of the Redis service. If it shows that for whatever reason it is down, then you should either check Redis logs, or use journalctl tool to look for system logs created by Redis.
I have seen that some installations might have redis as the command-line executable while some might have redis-server. So, please try one of these commands (one will work depending on the redis package):
sudo service redis-server restart
# OR
sudo service redis restart
If you have a newer Cent OS having systemctl installed, then try one of these:
sudo systemctl restart redis-server
# OR
sudo systemctl restart redis

Can't restart kestrel

I am using supervisor to run the kestrel process on Ubuntu 14.04.
Here is my supervisor config:
[program:website]
command=/usr/bin/dotnet /var/www/publish/Website.dll
directory=/var/www/publish/
autostart=true
autorestart=true
stderr_logfile=/var/www/website.err.log
stdout_logfile=/var/www/website.out.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=www-data
stopasgroup=true
stopsignal=INT
I have tried sudo service restart supervisor and supervisorctl restart website.
They both say they are stopping and starting process but my uploaded changes are not detected, it seems kestrel carries on running unaffected.
The only way I have of getting my changes to reflect is to restart the entire server which is inconvenient.
What is a better way for me to restart kestrel?

Denwer apache restart

I often restart apache during development e.g. for doggling on/off x-debug, update Doctrine cache...
Uppon installation Denwer puts 3 shortcuts on desktop Start Denwer, Stop Denwer and Restart Denwer. Those are pointed to appropriate .exe files. However Restart Denwer restarts all services including MySQL, hosts file, mail daemon which takes 10 sec+.
How can I restart apache only?
apache-restart.bat
cd /d z:\denwer\scripts\init.d
z:\usr\local\miniperl\miniperl.exe apache.pl restart

Monit on CentOS causes httpd.pid not to be created

The solution was to replace this line:
check process apache with pidfile /var/run/httpd.pid
With this line:
check process httpd with pidfile /var/run/httpd/httpd.pid
And I also removed the 'group apache'.
Original post:
After installing Monit on CentOS, and setting an alert for the Apache (httpd) service, the service no longer creates the /var/run/httpd.pid file.
The httpd service IS running properly.
On top of it, as if that's not enough, Monit reports the status of the service as: Execution failed
Naturally, the only way to restart such a service is by killing it, since the 'restart' script doesn't see any running process.
These are the contents of the /etc/monit.d/monitrc file:
set daemon 10
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: me#server.com }
set alert bugs#server.com
set httpd port 2812 and
# SSL ENABLE
# PEMFILE /var/certs/monit.pem
allow user:password
check process apache with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if cpu is greater than 180% for 1 cycles then alert
if totalmem > 1200 MB for 2 cycles then restart
if children > 250 then restart
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/sshd start"
stop program "/etc/init.d/sshd stop"
if failed port 22 protocol ssh for 5 cycles then restart
if 5 restarts within 25 cycles then timeout
Output of "service httpd restart":
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]
Any help will be greatly appreciated.
Try to replace stop program with /usr/sbin/httpd -k stop. It work for me.
I had the same problem but /usr/sbin/httpd -k stop didn't seem to help since this still tries to look up the process id from the pid file.
I opted for stop program = "/usr/bin/killall httpd". I don't think this is very elegant (probably kills open requests) but it was the only way I could find to restart apache and have the pid file recreated by monit.
I think that monit is doing a restart as 'stop; start' and is not waiting for 'stop' to finish before starting a new process, and thus is deleting the pid file at an inappropriate time. At least, that's my conclusion after tinkering with all this.
I found a reference to someone who fixed this issue by making monit sleep after the 'stop' statement.
Personally, I found that replacing 'restart' with 'start' when the http server is down worked just fine.