Stop/ Start app and DB after patching

gopalan

New Member
Joined
Mar 19, 2020
Messages
2
Reaction score
0
Credits
0
Everymonth our organisation has practice to apply linux patching and restart all app / db servers. My linux team person did helped however something is going wrong.
My question :
The app start and stop is a script.
Is there a way we call a script for stop and start app ?
Is there a way call the Stop.sh script while shutting down the server
After reboot it call the startup.sh ?
like startup.sh and stop.sh ?

This is my linux version.
3.10.0-1062.9.1.el7.x86_64 #1 SMP Mon Dec 2 08:31:54 EST 2019 x86_64 x86_64 x86_64 GNU/Linux
 
Last edited:


That looks like a redhat 7 or centos 7 kernel.
Generally the "scripts" that start and stop applications are caled systemd service files.

Uusally these files are installed when you install the application.
Here are some examples of how to use these scripts.

systemctl start postgresql
systemctl stop postgresql
systemctl status -l postgresql

systemctl enable mariadb
systemctl disable mariadb
systemctl mask mariadb
 
unfortunately we tried that option and for some reason the direct command of starting app is causing some issues. But if I stop and restart the app using the script that IBM has provided it is working perfectly fine. So is there a way to call a script in the systemctl or init.d ?
 
yes, there is...

I can show you an example systemd service file. You might already have one.

Normally these are in /usr/lib/systemd/system
but sometimes they are in /etc/systemd/system

they always end with a ".service" suffix. Like postgresql.service for example.

This is an example of what one looks like.



[Unit]
Description=DNS caching server.
After=network.target

[Service]
ExecStart=/usr/sbin/dnsmasq -k
ExecStop=/usr/sbin/dnsmasq -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target



Just change the Description to whatever makes sense.
Change the ExecStart and ExecStop lines to match whatever command line
you are currently using that works.

If you are running the service as a specific user we can add that.
If you need a specific environmental variable like JAVA_HOME we can also add that.
 

Members online


Top