Single Startup script for Apache/jboss


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Single Startup script for Apache/jboss
# 1  
Old 03-18-2011
Single Startup script for Apache/jboss

Hi,

I have apache ,jboss and jon instances on various linux boxes.I need to create a generic startup script to restart those instances on server reboot.The script requirement is :
It should take the name of instances from one text file named active-servers and recycle those instances.
1. start-mws-servers (generic script for /etc/rc.d but just create it in ~/bin dir for current testing)

It simply searches ~/bin/active-servers for active server recycle scripts
It executes each recycle script and passes it the 'start' command
It logs results to /tmp/start-mws-servers.log so we can review it after a machine recycle
Please help.

Regards,
Saurau
# 2  
Old 03-21-2011
Can you supply an active-servers text file for a server running apache, jboss and jon?
# 3  
Old 03-21-2011
Hi,

My active server text file will look like :

apache-instance1
apache-instance2
apache-instance3
ews-instance1
ews-instance2
ews-instance3
eap-instance1
eap-instance2
eap-instance3
rhq-agent
jon-123

It means apache instances will start from apache-,tomcat from ews-,jboss from eap- etc.

Regards,
Saurau
# 4  
Old 03-21-2011
How about something like this:

Code:
#!/bin/sh
LOGFILE=/tmp/start-mws-servers.log
SCRIPT_DIR=~/bin
 
logmsg () {
  echo $(date): $1 >> $LOGFILE
}
 
while read instance
do
    if [ -x  "${SCRIPT_DIR}/$instance" ] ; then
        logmsg "Recycle $instance..."
        "${SCRIPT_DIR}/$instance" start >> $LOGFILE 2>&1
    else
        logmsg "Cannot find recycle script for $instance - not starting"
    fi
done < "${SCRIPT_DIR}/active-servers"
logmsg "Start script execution complete"

This User Gave Thanks to Chubler_XL For This Post:
# 5  
Old 03-21-2011
Thanks a lot for your help.It's really good. I will try and you know, if any complication arises.

Regards,
Saurau.
# 6  
Old 03-26-2011
Hi,

Thanks it worked, however my active instances are installed on different path and also only start command wont work for all the instances.The script provided by you will work only when i make startup-scripts separately on the name of instances and then run the provided script.

Is there any way , to merge all the startup scripts in one , so that there will be single start up script.

Regards,
Saurabh Kumar.
# 7  
Old 03-27-2011
I'd assume that each instance would need to have some sort of configuration parameters (eg apache would have it's own httpd.conf to setup a different listen port, server root, etc).

One way to deal with this is enhance the details stored in your active-servers.txt eg:

Code:
[apache-instance1]
AUTOSTART=1
CMD=/usr/local/apache/bin/httpd -f /usr/local/apache/conf/instance1.conf
STARTDIR=/usr/local/bin/apache-instance1
 
[apache-instance2]
AUTOSTART=1
CMD=/usr/local/apache/bin/httpd -f /usr/local/apache/conf/instance2.conf
STARTDIR=/usr/local/bin/apache-instance2

Nice thing about this is you have a one-stop-shop for setting up all these servers, the down side is the start (and stop) scripts will need to be more complex to parse and validate this file.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Startup script

I can't quite find a clear answer on how to properly write a start up script. Does anybody have any ideas?? (3 Replies)
Discussion started by: Huitzilopochtli
3 Replies

2. Shell Programming and Scripting

Apache tomcat startup script not booting at startup.

I copied the script from an AskUbuntu post - #!/bin/bash ### BEGIN INIT INFO # Provides: tomcat7 # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop Tomcat server ### END INIT INFO ... (14 Replies)
Discussion started by: Hijanoqu
14 Replies

3. Shell Programming and Scripting

Recycle Jboss server script

Hello, I need help writing a script to restart our Jboss server when it crashes. I am not very good with scripting but here is the basics. 1) I'm hoping to use KornShell 2) The command to stop the Jboss is "/var/opt/HP/ALM/jboss/bin/run.sh stop" 3) I want to verify the jboss is stopped before... (1 Reply)
Discussion started by: Blogger11
1 Replies

4. AIX

startup script

Hi I need the below script to be started whenever I reboot my aix server ? #cat cdbegin /cdirect/cdunix/ndm/bin/cdpmgr -i /cdirect/cdunix/ndm/cfg/cbspsdb01/initparm.cfg Please suggest how to add this to the startup ? (2 Replies)
Discussion started by: samsungsamsung
2 Replies

5. Shell Programming and Scripting

Apache Startup Fails with PHP Error

Great tins massive! Im Manqoba from Midrand, South Africa... I have installed Apache and PHP on a solaris 9 box, using the packages below: apache-2.2.14-sol9-sparc-local php-5.2.13-sol9-sparc-local After installing the packages I edited my httpd.conf file, to load the php5 module when... (10 Replies)
Discussion started by: Macarena S.A
10 Replies

6. Shell Programming and Scripting

Script to monitor JBoss web server

Hello All, I need a shell script to monitor JBOSS web server.If the JBOSS web server is down, then the script should send a mail. Please help on this. Regards, Sachin (2 Replies)
Discussion started by: nsachin
2 Replies

7. AIX

Creating startup service for JBoss

Hello Friends, Does anyone know how to create a startup script for Jboss on IBM AIX 5.3? Please help me, I'd be highly grateful to you... Thanks & Regards, Vinit (0 Replies)
Discussion started by: vpatil6688
0 Replies

8. Shell Programming and Scripting

Solaris Startup script for Apache.

I'm running Solaris 5.9 and Apache 2.... I've created a startup script for Apache....but it doesn't work!!! it resides in /etc/init.d and has a link to /etc/rc3.d and if it run it as /etc/init.d/apache_start stop it stops the httpd services and /etc/init.d/apache_start start starts the... (3 Replies)
Discussion started by: Zak
3 Replies

9. Shell Programming and Scripting

Startup script

New in Unix, I am adding a line "route add 57.14.y.y 57.14.x.x" every day after rebooting the system. Where can I add the line so during boot up (the system is re-started every day by design (???) the line is executed? (I tried the /etc/rc2.d/S90 but for some reason the line needs to be added... (2 Replies)
Discussion started by: texaspanama
2 Replies
Login or Register to Ask a Question