Commit f2e1bd04 authored by lighta's avatar lighta

-Some scripts support

--Upd map Makefile.in to auto add header file in folder
--Upd configure to fix some debuging issue on some OS (-g flag issue)
--Upd athena-start, add --enlog option to create a log file with a tee. (all the normal console could now be logged into that file) thx to Beanux
nb : this logging option doesn't actually support file oversize
parent a9b48baa
......@@ -5,117 +5,145 @@
inst_launch_workaround
PATH=./:$PATH
print_start() {
# more << EOF
echo "Athena Starting..."
echo " (c) 2013 rAthena Project"
echo ""
echo ""
echo "checking..."
#EOF
# more << EOF
echo "Athena Starting..."
echo " (c) 2013 rAthena Project"
echo ""
echo ""
echo "checking..."
#EOF
}
get_status(){
PIDFILE=.$1.pid
if [ -e ${PIDFILE} ]; then
ISRUN=$(ps ax | grep $(cat ${PIDFILE}) | grep $1)
PSRUN=$(echo "$ISRUN" | awk '{ print substr( $0, 0, 7) }')
fi
return $PSRUN
PIDFILE=.$1.pid
if [ -e ${PIDFILE} ]; then
ISRUN=$(ps ax | grep $(cat ${PIDFILE}) | grep $1)
PSRUN=$(echo "$ISRUN" | awk '{ print substr( $0, 0, 7) }')
fi
return $PSRUN
}
#cheking if already started, launch and mark in log
start_serv(){
LOGFILE="log/$1.log"
get_status $1
echo "My logfile=${LOGFILE}"
if [ -z ${PSRUN} ]; then
exec ./$1&
echo $! > .$1.pid
echo "Server '$1' started at `date +"%m-%d-%H:%M-%S"`"
echo "Server '$1' started at `date +"%m-%d-%H:%M-%S"`" >> ${LOGFILE}
else
echo "Can't start '$1', cause is already running p${PSRUN}"
echo "Can't start '$1', cause is already running p${PSRUN}" >> ${LOGFILE}
fi
get_status $1
if [ $2 ]; then #is logging on ?
LOGFILE="log/$1.launch.log"
LOGRUN="log/$1.log"
FIFO="$1_fifo"
echo "stat_serv, log is enabled"
echo "My logfile=${LOGFILE}"
if [ -z ${PSRUN} ]; then
if [ -e ./${FIFO} ]; then rm "$FIFO"; fi
mkfifo "$FIFO"; tee "$LOGRUN" < "$FIFO" & "./$1" > "$FIFO" 2>&1 & PID=$!
#"./$1" > >(tee "$LOGRUN") 2>&1 & PID=$! #bash only
echo "$PID" > .$1.pid
echo "Server '$1' started at `date +"%m-%d-%H:%M-%S"`" | tee ${LOGFILE}
else
echo "Can't start '$1', cause is already running p${PSRUN}" | tee ${LOGFILE}
fi
else
if [ -z ${PSRUN} ]; then
./$1&
echo "$!" > .$1.pid
echo "Server '$1' started at `date +"%m-%d-%H:%M-%S"`"
else
echo "Can't start '$1', cause is already running p${PSRUN}"
fi
fi
}
#experimental
watch_serv(){
LOGFILE=./log/$1.log
ulimit -Sc unlimited
LOGFILE="log/$1.launch.log"
LOGRUN="log/$1.log"
FIFO="$1_fifo"
ulimit -Sc unlimited
while true; do
get_status $1
if [ -z ${PSRUN} ]; then
$count=$count+1
echo "server '$1' is down" >> ${LOGFILE}
echo "restarting server at time at `date +"%m-%d-%H:%M-%S"`">> ${LOGFILE}
exec ./$1&
echo $! > .$1.pid
if [ $3 ] && [ $3 -lt $count ]; then break; fi
else sleep $2
fi
done
while true; do
get_status $1
if [ -z ${PSRUN} ]; then
$count=$count+1
echo "server '$1' is down" | tee ${LOGFILE}
echo "restarting server at time at `date +"%m-%d-%H:%M-%S"`" | tee ${LOGFILE}
if [ -e ./${FIFO} ]; then rm "$FIFO"; fi
mkfifo "$FIFO"; tee "$LOGRUN" < "$FIFO" & "./$1" > "$FIFO" 2>&1 & PID=$!
echo "$PID" > .$1.pid
if [ $3 ] && [ $3 -lt $count ]; then break; fi
else sleep $2
fi
done
}
restart(){
$0 stop
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
while true; do
get_status ${i}
if [ ${PSRUN} ]; then echo "'${i}' is still running p${PSRUN} waiting end"; sleep 2;
else break; fi
done
done
$0 stop
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
FIFO="$1_fifo"
while true; do
get_status ${i}
if [ ${PSRUN} ]; then echo "'${i}' is still running p${PSRUN} waiting end"; sleep 2;
else
if [ -e ./${FIFO} ]; then rm "$FIFO"; fi
break
fi
done
done
$0 start
}
case $1 in
'start')
print_start
check_files
echo "Check complete."
echo "Looks good, a nice Athena!"
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
start_serv $i
done
echo "Now Started Athena."
;;
'watch')
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
watch_serv $i 10 3
done
echo "Now watching Athena."
;;
'stop')
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
PIDFILE=.${i}.pid
if [ -e ./${PIDFILE} ]; then
kill $(cat ${PIDFILE})
rm ${PIDFILE}
print_start
check_files
echo "Check complete."
echo "Looks good, a nice Athena!"
if [ "$2" = "--enlog" ]; then
ENLOG=1
echo "Logging is enable"
else
echo "Logging is disable"
fi
done
;;
'restart')
restart
;;
'status')
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
start_serv $i $ENLOG
done
echo "Now Started Athena."
;;
'watch')
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
watch_serv $i 10 3
done
echo "Now watching Athena."
;;
'stop')
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
PIDFILE=.${i}.pid
if [ -e ./${PIDFILE} ]; then
kill $(cat ${PIDFILE})
rm ${PIDFILE}
fi
done
;;
'restart')
restart
;;
'status')
for i in ${L_SRV} ${C_SRV} ${M_SRV}
do
get_status ${i}
if [ ${PSRUN} ]; then echo "'${i}' is running p${PSRUN}"; else echo "'${i}' seem down"; fi
done
;;
*)
echo "Usage: athena-start { start | stop | restart | status | watch }"
read -p "Enter a valid option: " readEnterKey
;;
*)
echo "Usage: athena-start { start | stop | restart | status | watch }"
echo "option --enlog will tee output into a logfile"
read -p "Enter a valid option: " readEnterKey
$0 $readEnterKey
;;
;;
esac
#! /bin/sh
# From configure.in Revision: 17342 .
# From configure.in Revision.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69.
#
......@@ -5187,9 +5187,11 @@ case $enable_debug in
;;
"yes")
CFLAGS="$CFLAGS -g -DDEBUG"
LDFLAGS="$LDFLAGS -g"
;;
"gdb")
CFLAGS="$CFLAGS -ggdb -DDEBUG"
LDFLAGS="$LDFLAGS -g"
;;
esac
......@@ -6148,10 +6150,13 @@ else
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: Configure finish, CFLAGS= $CFLAGS" >&5
$as_echo "$as_me: Configure finish, CFLAGS= $CFLAGS" >&6;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: LDFLAGS=$LDFLAGS" >&5
$as_echo "$as_me: LDFLAGS=$LDFLAGS" >&6;}
#AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
#AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
{ $as_echo "$as_me:${as_lineno-$LINENO}: Configure finish, CFLAG= $CFLAGS" >&5
$as_echo "$as_me: Configure finish, CFLAG= $CFLAGS" >&6;}
###############################################################################
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
......
......@@ -649,9 +649,11 @@ case $enable_debug in
;;
"yes")
CFLAGS="$CFLAGS -g -DDEBUG"
LDFLAGS="$LDFLAGS -g"
;;
"gdb")
CFLAGS="$CFLAGS -ggdb -DDEBUG"
LDFLAGS="$LDFLAGS -g"
;;
esac
......@@ -915,8 +917,10 @@ else
AC_MSG_RESULT([no])
fi
AC_MSG_NOTICE([Configure finish, CFLAGS= $CFLAGS])
AC_MSG_NOTICE([LDFLAGS=$LDFLAGS])
#AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
#AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
AC_MSG_NOTICE([Configure finish, CFLAG= $CFLAGS])
###############################################################################
AC_OUTPUT
......@@ -17,17 +17,10 @@ MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \
storage.o skill.o atcommand.o battle.o battleground.o \
intif.o trade.o party.o vending.o guild.o pet.o \
log.o mail.o date.o unit.o homunculus.o mercenary.o quest.o instance.o \
buyingstore.o searchstore.o duel.o pc_groups.o elemental.o cashshop.o channel.o
MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) \
obj_sql/mapreg_sql.o
MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \
chat.h itemdb.h mob.h script.h path.h \
storage.h skill.h atcommand.h battle.h battleground.h \
intif.h trade.h party.h vending.h guild.h pet.h \
log.h mail.h date.h unit.h homunculus.h mercenary.h quest.h instance.h mapreg.h \
buyingstore.h searchstore.h duel.h pc_groups.h elemental.h cashshop.h channel.h\
../config/core.h ../config/renewal.h ../config/secure.h ../config/const.h \
../config/classes/general.h
buyingstore.o searchstore.o duel.o pc_groups.o elemental.o cashshop.o channel.o mapreg_sql.o
MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%)
MAP_H = $(shell ls ../map/*.h) \
$(shell ls ../config/*.h)
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment