How to make a systemctl service not close other services - apache

Below is the BHd.service file; this is the first time I've done this, and everything is finally working perfectly except that when I stop the service, it always without fail stops httpd (and likely other services listed here). I sincerely have looked everywhere for the answer. I don't think it should be doing this.
Log story short, I need smb, nfs, httpd and mariadb to be running before this unit start. I do not want them to be stopped after the unit is stopped or reloaded; for now, firewalld must be off. I honestly can't tell what line is affecting the systemctl stop command, everything I read indicates that Requires and After only affect systemctl start.
[Unit]
Description=BH
Documentation=somewhere.com
Wants=smb.service nfs.service
After=httpd.service mariadb.service
Requires=httpd.service mariadb.service
Conflicts=firewalld.service
[Service]
Type=forking
PIDFile=/var/run/BHd.pid
ExecStart=/usr/bin/python /var/www/html/pythonscripts/BHd.py start
ExecStop=/usr/bin/python /var/www/html/pythonscripts/BHd.py stop
[Install]
Alias=BHd
WantedBy=smb.service nfs.service
RequiredBy=httpd.service mariadb.service
EDIT: More info
[root#BHDEMO ~]# systemctl -l | grep BH
BHd.service loaded failed failed Description
[root#BHDEMO ~]#

Short Answer: systemctl disable BHd
Long Answer:
Well, I feel stupid... I'm sure some of you will think "this guy is writing a 40k line service but didn't know that!"... yes, that's how us computer engineers roll, lol.
The Solution:
After editing this file over and over in an attempt to get it working, I never tried systemctl disable BHd... that did it... I had a few lines in the Install section early, WantedBy and RequiredBy as seen above. I realized about 5 hours ago that this was not correct and deleted it. Unfortunately, just doing another enable is not sufficient, as those lines created directories that needed to be uninstalled with disable, then reinstalled with enabled without the added files and folders. Almost sounds like a linux bug that should be fixed, imagine how many like me over the years wasted so much time.

Related

Service openfire startup with script openfire.sh

look, always should run this command:
# cd /opt/openfire/bin/
# ./openfire.sh start
Openfire 3.6.4 [19-may-2009 17:43:25]
Console d'administration en écoute sur:
http://server.xxxxx.com:9090
https://server.xxxxx.com:9091
Index opened.
Index thread started
If I close the putty command line… the service openfire down… and after is neccessary again run… somebody know some way for always this service are permanently up ?
Thanks
All of the Openfire distributions should come with some kind of daemon or service script. It's hard to tell exactly what operating system you're on, but try typing something like this:
service openfire start
Also, I'm noticing that you're using a very old version of Openfire (it's from 2009!). I urge you to upgrade. Not only were many improvements and new features added, but security has been improved greatly over the years too.

Hosts in Nagios are disappearing

This may belong in ServerFault, but I wanted to approach this community first. If this is not correct, please move this thread or close and I will open on the correct thread.
PROBLEM:
Hosts, along with their associated services, disappear and reappear upon refresh (F5 / Ctrl+F5 / etc).
STEPS TO REPRODUCE:
1. Log into Nagios
2. Click Service Detail
3. See a breakdown of services but you don't see the last one you added.
4. Refresh screen by using F5 / Ctrl+F5 / etc and it doesn't show up still
5. Refresh screen by using F5 / Ctrl+F5 / etc and it doesn't show up still
6. Refresh screen and it will show up.
(!) - Steps 4-6 vary
WHAT I'VE TRIED:
Restarting Nagios service (service Nagios restart)
Restarting HTTPD service (service httpd restart)
Restarting VPS
Refresh browser including "Clear Cache and Hard Reload"
Tried different browsers
Tried different computers
Tried different networks
SCREENSHOTS:
GOOD
https://i.imgur.com/KUW5C6E.png
BAD
https://i.imgur.com/rWFLEaf.png
POSSIBLE CAUSE:
The reason we're in this situation now is because we had an intern add this latest host and its associated service. He added it correctly, and I even checked his work. He did the normal preflight but instead of issuing the reset command via SSH he issued the command on the Web interface itself by accessing "Process Info > Restart the Nagios process". Seems like it would work OK, but we've never restarted like this and is the only reason I suspect it's the culprit of the issue we are seeing. Is there something different that this restart does over the normal SSH restart?
EDIT: To add to all of this, we have updated a different file today, unrelated to this host or it's services and Nagios is not updating.
Thanks for helping!
Rich
EXTRA:
Here is a screenshot of the config file:
https://i.imgur.com/2UsYZcw.png
This can happen if you have multiple Nagios services running, There could be a secondary instance of the service running which hasn't been updated with the new configuration files as it technically hasn't been restarted. I've had this happen once or twice.
First, shut down Nagios
service nagios stop
Next, kill all remaining instances.
killall -9 nagios
Finally, start Nagios back up
service nagios start
That should fix your problem.

Apache not starting, fails silently/hangs

I had a web server that got overloaded. I attempted to stop apache but it just hung so I kill -9 the apache pid.
When trying to run
sudo /etc/init.d.apache2 start
or any derivative thereof, nothing happens. The command doesn't return. There is no error in log or at command line. I just get Starting web server: apache2 and the cursor keeps blinking. I've waited 30 minutes and still nothing. The server has 10G of memory free.
I running Debian wheezy.
Start by looking at the log files. That should contain the reason.
If there is nothing in the log files, troubleshoot using strace shown here : https://serverfault.com/questions/150249/best-way-to-troubleshoot-apache-not-starting
strace showed it was hanging on an nfs4 mountpoint that was not functioning properly.

Making Config for Monit to check program started from bash

I'm hoping someone out there is used to monit and can help me.
Im running a home data server, with Ubuntu 13.10.
I have CGminer setup to start when the PC boots, from a bash script of my own creation. It contains a few tweaks and setting that need running before it gets going.
But if for some reason my interweb goes down...cgminer will close after a small amount of time. Now, if im asleep, and it closes. That valuable mining time, and a waste of the electric. So I'm looking into monit as a way of fixing that.
Im hoping to be able to have monit (or something similar, doesnt have to be monit) Start CGMiner from my script, check every so often that CGminer is still running, and if not, restart it from my script.
I just cant get my head around the config file for monit...Help would be awesome
Yes, you can achieve that with monit. You only need that your start script writes pid into pidfile:
check process xyz with pidfile /var/run/xyz.pid
start = "/bin/xyz start"
stop = "/bin/xyz stop"

How to tell supervisor to restart processes when app code changed?

I am new to Tornado and supervisor. I have deployed a tornado app on Debian server and now it is running fine under supervisor/nginx. After that, I made a small change on the app's template file but it does not take effect apparently because the tornado processes need to be restarted. But I don't know to do so. I tried different things like
service supervisor restart
and also in supervisorctl command line I tried restart, reload, update etc.
But the old process are still running and the change in code still not applied. So wondering how to instruct supervisor to restart the app processes and ideally make supervisor sensitive to code change by adding some commands into supervisor.conf
Ok, I figured out. Here is the answer:
supervisor> restart all
and check whether really restarted:
supervisor> status
tornadoes:tornado-8000 RUNNING pid 17697, uptime 0:00:20
tornadoes:tornado-8001 RUNNING pid 17698, uptime 0:00:20
tornadoes:tornado-8002 RUNNING pid 17707, uptime 0:00:19
tornadoes:tornado-8003 RUNNING pid 17712, uptime 0:00:18