Running "sudo /sbin/service --status-all" restarts a service (Apache) - linux

I'm looking to understand how running the command "sudo /sbin/service --status-all" on a RedHat 6.7 64bit system could restart Apache?
I've always used this command to list all running and stopped services, this is the first time I've seen it restart a service though. Is this down to a bad Apache config or can issuing this command restart services in certain circumstances?
Update:
The status of httpd is that it is stopped:
sudo /etc/rc.d/init.d/httpd status
httpd is stopped
sudo /etc/init.d/httpd status
httpd is stopped
If I run "sudo /sbin/service --status-all" I see:
X is installed
Y is running...
X is stopped
httpd (pid xxx) already running
root xxx 1 0 18:10 ? 00:00:00 /usr/sbin/httpd -f
/httpd.conf -k start

Related

GitHub action self-host runner as service fails

I have installed GitHub self-hosted runner on my Ubuntu system. Getting below error when i try to configure it as service.
$ sudo ./svc.sh start
Failed to start actions.runner._services.Linux-Host01.service: Unit actions.runner._services.Linux-Host01.service is not loaded properly: Exec format error.
See system logs and 'systemctl status actions.runner._services.Linux-Host01.service' for details.
Failed: failed to start actions.runner._services.Linux-Host01.service
$ systemctl status actions.runner._services.Linux-Host01.service
● actions.runner._services.Linux-Host01.service - GitHub Actions Runner (_services.Linux-Host01)
Loaded: error (Reason: Exec format error)
Active: inactive (dead)
$ cat /etc/systemd/system/actions.runner._services.Linux-Host01.service
[Unit]
Description=GitHub Actions Runner (_services.Linux-Host01)
After=network.target
[Service]
ExecStart=/home/admin.user/actions-runner/runsvc.sh
User=admin.user
WorkingDirectory=/home/admin.user/actions-runner
KillMode=process
KillSignal=SIGTERM
TimeoutStopSec=5min
[Install]
WantedBy=multi-user.target
$ sudo journalctl -u actions.runner._services.Linux-Host01.service -f
Aug 04 08:40:47 Linux-Host01 systemd[1]: /etc/systemd/system/actions.runner._services.Linux-Host01.service:7: Invalid user/group name or numeric ID: admin.user
Additionally have provided executable permission to actions.runner._services.Linux-Host01.service but still it results same error.
What is wrong here?
I have changed User=admin.user to User=uid in the /etc/systemd/system/actions.runner._services.Linux-Host01.service file and then executed
systemctl daemon-reload
Now action service started and it is running fine.
Good morning,
First of all stop the service:
sudo ./svc.sh stop
Then make sure you have given permissions to the user:
sudo usermod -a -G <USER>
Now try to start the service:
sudo ./svc.sh start
And tell me if this works when check the status.
If not works please do the same but sudo permissions:
sudo su
And then try again all without sudo command because you are actually on root.
Have a great day!
This simply means you've not installed the runner
sudo ./svc.sh install // install the runner
sudo ./svc.sh start // then start it
Remember, this is the best way to go about it than using the ./run.sh script, as the runner will always be running in the background.
Use sudo ./svc.sh status to confirm that the runner is up and running.

How to run an Ubuntu NFS V4 kernel server in an Ubuntu docker instance without port mapper?

I need to operate a NFS server in docker in pure V4 mode, i.e. without portmapper port 111. (Reason: NFS server in Docker in WSL2 in Windows.)
I found instructions how to operate the Ubuntu default kernel NFS server without port 111 being open:
From https://peteris.rocks/blog/nfs4-single-port/
$ sudo vim /etc/default/nfs-kernel-server
...
RPCMOUNTDOPTS="--no-nfs-version 2 --no-nfs-version 3 --nfs-version 4 --no-udp"
RPCNFSDOPTS="--no-nfs-version 2 --no-nfs-version 3 --nfs-version 4 --no-udp"
...
$ sudo systemctl disable --now rpcbind.service rpcbind.socket
$ sudo systemctl mask rpcbind.service rpcbind.socket
However, this instructions rely on the commands "systemctl disable/mask" which are not available in my Ubuntu docker image, as there's no systemd or init around naturally in docker. When I exclude versions 2 and 3 in /etc/default/kernel-server and start nfs, I get the error message:
Not starting: portmapper is not running
Questions:
How can I run a pure NFS V4 tftp server in docker (Ubuntu) that does not need portmapper / port 111 ?
How can I do systemctl disable --now rpcbind-service rpcbind-socket and systemctl mask epcbind-service rpcbind.socket when I have no systemctl available ?
Do I maybe need to patch /etc/init.d/nfs-kernel-server start ?
Are there better alternatives to nfs-kernel-server for a pure V4 mode ?
Thanks very much.
Solution:
A) Disable check for rpcbind in init script
sudo vim /etc/init.d/nfs-kernel-server
Remove 8 lines near #See if rpcbind is running ... if ...fi
B) Use --privileged when starting rocker run

Is there a way to safely kill all apache processes running in background?

In a server that I'm working on, There are many apache processes running in background. Is it safe to kill all the processes? If so, please guide me the steps involved in it. I have seen 12 httpd commands running as per result of top command, hope it helps in debugging the problem.
You can kill httpd process using this command
sudo kill `pgrep httpd`
Source: https://www.cyberciti.biz/faq/kill-process-in-linux-or-terminate-a-process-in-unix-or-linux-systems/
OR
Stop the Apache service with:
sudo systemctl stop httpd.service
Prevent Apache from loading when the system boots:
sudo systemctl disable httpd.service
Source: https://phoenixnap.com/kb/how-to-restart-apache-centos-linux

Gitlab Cannot start runsv is not running

I just upgraded my gitlab-ce version to the latest version using this command
sudo yum install gitlab-ce-12.1.3-ce.0.el7.x86_64
the upgrade works well, but after restart the gitlab service won't start,
when I run this command
sudo gitlab-ctl start
fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-monitor: runsv not running
fail: gitlab-workhorse: runsv not running
fail: grafana: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running
fail: redis: runsv not running
fail: redis-exporter: runsv not running
fail: sidekiq: runsv not running
fail: unicorn: runsv not running
and then I try to start the gitlab-runsv by using this command
systemctl start gitlab-runsvdir.service
But it freezes and not doing anything!!, I must use the CTRL+C to quit
and when I run the journal-ctl it don't showing anything.
journalctl -u gitlab-runsvdir.service
-- No entries --
My Environment is Centos 7.
I faced the problem on my ubuntu-20. Previously i had disabled my gitlab-runsvdir.service. That was the reason for my problem. so what i did
sudo systemctl enable gitlab-runsvdir.service
sudo systemctl start gitlab-runsvdir.service
I left this answer on a similar issue: Gitlab not starting after upgrade to Ubuntu 18.04
I ran into a similar runsv error, but only saw it for once service, not the whole list you have. These steps are a log of my attempts to get it working - probably not a direct line, but my local Gitlab does work now:
In the CentOS vm:
vi /etc/gitlab/gitlab.rb
change the external_url from http://example.gitlab.com to http://192.168.1.131
sudo gitlab-ctl reconfigure
first observed the error runsv not running
yum update -y
sudo gitlab-ctl status
sudo gitlab-ctl restart
sudo gitlab-ctl reconfigure
systemctl start gitlab-runsvdir.service
systemctl status gitlab-runsvdir.service
sudo gitlab-ctl reconfigure
still saw an error about runsv not running, several times, but it was never a blocker and the reconfigure was successful
On host
navigate to 192.168.1.131
See the prompt for root password
As for the issue with Postgres, I'm not sure
I did the yum update and restart again after that I did the gitlab-ctl reconfigure, now the gitlab services are working again.

Amazon EC2 - Apache server restart issue

When i run this command
sudo /etc/init.d/httpd restart
it gives below error
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(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]
i checked running programs at port 80 by using
netstat -lnp | grep :80 (it gives below output)
tcp 0 0 :::80 :::* LISTEN 21739/httpd
why i am not able to stop stop apache by using sudo /etc/init.d/httpd restart?
below commands work without issue
sudo apachectl stop
sudo apachectl start
i am using linux micro instance of amazon ec2
I ran into this problem when I installed apache from source, but then tried to run
$ sudo /etc/init.d/httpd restart
which was using a pre-installed version of apache. The stop directive in /etc/init.d/httpd was not removing the httpd.pid file that was created when starting the source-installed version of apache.
To determine if this is also the reason for your problem, find where the httpd.pid file is getting set when you run
$ sudo apachectl start
If you installed from source and apache2 is living in /usr/local/apache2, then the httpd.pid file should get created in /usr/local/apache2/logs. When you stop apache by running
$ sudo apachectl stop
this file should get removed. So to test if the httpd.pid file is causing your problem, start apache by calling
$ sudo apachectl start
and locate the httpd.pid file. Then try stopping apache by using
$ sudo /etc/init.d/httpd stop
If the original httpd.pid file is still present, then that is why apache is unable to start when you use
$ sudo /etc/init.d/httpd start
To get my /etc/init.d/httpd file to work correctly, I explicitly put the call to apachectl in the start and stop methods:
#!/bin/bash
# /etc/init.d/httpd
#
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
pid=/usr/local/apache2/logs/httpd.pid
prog=httpd
RETVAL=0
start() {
echo -n $"Starting $prog: "
$apachectl -k start
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
$apachectl -k stop
RETVAL=$?
echo
}
I tried this and it works:
sudo fuser -k -n tcp 80
sudo service httpd start
Hope this will help you!
Cheers
I feel its better to kill the process itself, find out the process id and kill it and then do a fresh start, it should work fine
I have had this issue very rarely over the last couple years with a server I've been managing. Unfortunately, if you are getting FAILED after trying to restart, the process that's managing the connection on port 80 won't release it's hold on that port.
I would try a full "sudo /etc/init.d/httpd stop" wait for that to finish or fail.
If that doesn't fix it you'll have to restart the server completely. Hopefully, it's configured to start everything up automatically on restart, but that isn't guaranteed.
"apachectl" is also great tool for Apache, but it may not be on this server, it depends on the install and linux distro used.
If after rebooting the server, apache still fails to start, something bad has happened. I'd consider pulling all the website and conf files for creating a new server at that point, but the apache start, and then failed message output should give you some idea of where to look in the Logs about why it cannot start.

Resources