Jump to content

[Linux] athena-start


Calmcacil

Recommended Posts


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  4
  • Reputation:   2
  • Joined:  01/05/12
  • Last Seen:  

The athena-start script could use some improvement, this is just a suggestion for a quick fix.

What this does is basically telling the start script to sleep for 5 seconds before executing the map-server, I think this is useful due to the whole issue where you run restart and your map server doesnt get started because its still waiting for the old instance to close (cant bind Ip due to port in use.) that you generally experience upon calling a restart making the restart command not really do much unless the map server has actually crashed.

edit: Adding a check to see if map server is already running, then posting new diff.

edit2: Added check to see if the map server is already running, if it is the script will output this information to the user, wait for 5 seconds and then start the server, if its not found. It will start the map server normally.

athena-start.diff

Edited by Calmcacil
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  257
  • Reputation:   253
  • Joined:  11/29/11
  • Last Seen:  

I havent ever used the athena-start file without modifying it to use screen.

Perhaps something that should be considered.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

I have personally never used it either. I've always used each server on its own screen (Screens: Login/Char/Map). Would be an interesting idea of athena-start automatically started all servers in their respective screens =]

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  257
  • Reputation:   253
  • Joined:  11/29/11
  • Last Seen:  

#!/bin/sh
# athena starting script by rowla
# modified by [email protected] (NL101541)

PATH=./:$PATH

L_SRV=login-server_sql
C_SRV=char-server_sql
M_SRV=map-server_sql

print_start() {
#    more << EOF
echo "Athena Starting..."
echo "		    (c) 2003 Athena Project"
echo "			  modified by [email protected]"
echo ""
#echo "Debug informations will appear,"
#echo "since this is a test release."
#echo ""
echo "checking..."
#EOF
}

check_files() {

   for i in ${L_SRV} ${C_SRV} ${M_SRV}
   do
    if [ ! -f ./$i ]; then
	    echo "$i does not exist, or can't run."
	    echo "Stop. Check your compile."
	    exit 1;
    fi
   done

#    more << EOF
echo "Check complete."
echo "Looks good, a nice Athena!"
#EOF
}


case $1 in
   'start')
    print_start
    check_files

    exec screen -d -m -S login .{L_SRV}&
    exec screen -d -m -S char ./${C_SRV}&
    exec screen -d -m -S map ./${M_SRV}&

    echo "Now Started Athena."
    echo "To view one of the servers type as shown:"
    echo "Login: screen -r login"
    echo "Char : screen -r char"
    echo "Map  : screen -r map"
    echo "To stop viewing a screen hold Ctrl+A and tap D"
;;
   'stop')
    ps ax | grep -E "${L_SRV}|${C_SRV}|${M_SRV}" | awk '{print $1}' | xargs kill
;;
   'restart')
    $0 stop
    $0 start
;;
   *)
    echo "Usage: athena-start { start | stop | restart }"
;;
esac

as you wish sir.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  737
  • Reputation:   216
  • Joined:  11/29/11
  • Last Seen:  

Better use a while loop if you wanna do this check, since it may not finish on 5s.

http://pastebin.com/jR91fv1U

Also you check it's quite overkill with ps -ax, juste like the one in stop in fact instead using pkill. (btw stop quite annoying if you have multiple server running with same name).

http://mywiki.wooledge.org/ProcessManagement

Oh and little note I said to update this thing a month ago at least..

Edited by Lighta
Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  2
  • Reputation:   0
  • Joined:  01/18/12
  • Last Seen:  

Honestly, I don't see the point in improving the script when there are better alternatives. I use daemontools's supervise. My run scripts look similar to this:

#!/bin/sh
cd /eathena/server/trunk
exec /eathena/server/trunk/char-server_sql > /dev/null

This way, if the server crashes it automatically restarts.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...