Anope IRC Services

Anope.org => Anope General => Topic started by: scarcorp on February 18, 2008, 12:22:51 AM

Title: Strange thing happening
Post by: scarcorp on February 18, 2008, 12:22:51 AM
My IRC server & Anope works like a charm, great job people :)

The only thing is this:
After the server & services have been running for a few days I get this Notice:

*** Notice -- Link [@127.0.0.1.57085] cancelled, server
 services.scarcorp.com.au already exists from services.scarcorp.com.au

And it comes up every 5 minutes, which incidentally is the contrab time check I've setup.

I've looked at the contrab, the services set up etc, but can't figure it out.

Has anyone else come across this problem?

It's not terribly important since everything else works fine, but being a bit of a perfectionist I like things to run as expected hehe

Cheers,
Johnny
Title:
Post by: GhosT on February 18, 2008, 06:23:54 AM
You might set up crontab for anope not properly.
Title:
Post by: scarcorp on February 18, 2008, 06:45:42 AM
Thanks for your reply,

This is my crontab:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/ircadmin/services/services.chk >/dev/null 2>&1

And this is services.chk:

#!/bin/sh

# Crontab script for Anope
#
# To know how to install the crontab, read the INSTALL file.

###############################################################
# CONFIGURATION
###############################################################

# Anope binary directory
ANOPATH=/home/ircadmin/services/

# Name of the pid file
ANOPIDF=services.pid

# Name of the executable
ANOPROG=services

# Parameters to pass to the executable
ANOARGS=""
#ANOARGS="-debug"

###############################################################
#                 DON'T EDIT ANYTHING BELOW                   #
###############################################################

PATH=/bin:/usr/bin:/usr/local/bin

ANOPID=

cd $ANOPATH

if [ -f $ANOPIDF ]
then
        ANOPID=`cat $ANOPIDF`
        if [ `ps auwx | grep $ANOPROG | grep $ANOPID | grep -v -c grep` = 1 ]
        then
                exit
        fi
        rm -f $ANOPIDF
fi

./$ANOPROG $ANOARGS

I have it set up to run under it's own user: ircadmin

If you see anything incorrect, I'd appreciate it if would point it to me.  I'm quite a novice at this.

Thanks again,
Johnny
Title:
Post by: katsklaw on February 18, 2008, 11:26:15 AM
only 2 things that cause an auto-connect attempt and that's crontab and an auto-connect entry in your link block.
Title:
Post by: scarcorp on February 18, 2008, 12:08:28 PM
Ok ... Thanks ... Funny thing is it's ok for a few days ... then it tries to connect every 5 mins ... although the service is already running & operating as expected.

Cheers,
Johnny
Title:
Post by: Jan Milants on February 18, 2008, 12:15:34 PM
yeah.. i have experienced and seen this with others before... for some reason the services.pid file disappears and then the cronjob thinks anope isn't running anymore and tries to start a new instance... which is then rejected by the ircd of course.
A quick fix is to recreate the services.pid with anopes pid in it, but that won't prevent it from happening again...
Title:
Post by: scarcorp on February 18, 2008, 12:18:58 PM
Maybe I'll try creating a copy of the pid file and add a crontab to check for it's existence, then have it copied.
We'll see
:)
Title:
Post by: scarcorp on February 18, 2008, 04:10:12 PM
No didn't work ... It's a mistery ... everthing seems setup up ok!
Title:
Post by: scarcorp on February 19, 2008, 06:33:26 AM
Oh well, apart from a bit of extra CPU processing time, it's not a real drama.
If anyone has experienced this before, or know of a solution, your thoughts would be welcome.

I wonder if it has anything to do with crontab itself?  That's a little out of my depth lol

Thanks all.
:)

[Edited on 19-2-08 by scarcorp]
Title:
Post by: katsklaw on February 19, 2008, 09:58:48 PM
Actually now that I think about it. It's been reported in the past that some users that use the anope's example.chk cron script found that their pid files get deleted at the wrong times. This is an occasional occurance adn without that pid file the check script will attept to start Anope, even if it's running.

Personally I use a custom script and haven't had such bad luck.
Title:
Post by: scarcorp on February 21, 2008, 10:20:40 PM
Problem solved!
I simply added a crontab entry to copy a backup of services.pid and after a few days it seems to be ok.

Many thanks for everyone who helped :)

Cheers,
Johnny
:)
Title:
Post by: scarcorp on February 26, 2008, 12:03:14 AM
Back to square one again!

I've done away with services.chk there seems to be an error in the script, I'm no expert at writing scripts, but it seems the script's logic deletes the services.chk file, and then runs ./services again.

if [ -f $ANOPIDF ]     <------ this checks if services.pid exists
then
ANOPID=`cat $ANOPIDF`   <--------- if does it gets the pid number
if [ `ps auwx | grep $ANOPROG | grep $ANOPID | grep -v -c grep` = 1 ]    <------- this checks if the service is running
then
exit      <--------- yes it is running so it exits the script.
fi
rm -f $ANOPIDF     <------- no it's not, so it deletes the pid file
fi

./$ANOPROG $ANOARGS     <-------- starts services again.

Problem is for some reason the script deletes the pid file and then on it's next check it tries to run services even though its already running!

Oh well...
Cheerrs.
Title:
Post by: Jan Milants on February 26, 2008, 12:08:22 AM
The problem is known... what isn't known is what causes it, since it is only a small minority of people that ever experience this problem, and even then it doesn't always happen again...
Title:
Post by: katsklaw on February 26, 2008, 11:09:18 AM
several people tend to use a modified version of the chk script that comes with UnrealIRCd and have better luck.
Title:
Post by: scarcorp on February 26, 2008, 11:41:01 AM
Would someone care to supply me with one of their modified scripts?

Johnny
Title:
Post by: katsklaw on February 26, 2008, 08:26:03 PM
?? .. user the one that come with Unreal and put anopes name in it .. it's not that hard.
Title:
Post by: TommyGun on March 17, 2008, 06:50:29 PM
katsklaw, could you post your .chk file maybe? Im having this problem too, cant get it fixed.

Thanks
Title:
Post by: katsklaw on March 18, 2008, 03:38:15 AM
Quote
Originally posted by TommyGun
katsklaw, could you post your .chk file maybe? Im having this problem too, cant get it fixed.

Thanks


What IRCd do you use?
Title:
Post by: scarcorp on March 18, 2008, 05:37:02 AM
I noticed that I had crontabs setup as root as well as "ircadmin", after sorting that out and just using the ircdchk & crontab under owner "ircadmin" the problem has resolved itself.
<well - I am rather new at all this but its fun!>

Cheers everyone.:)
Title:
Post by: TommyGun on March 18, 2008, 05:19:30 PM
Quote
Originally posted by katsklaw
Quote
Originally posted by TommyGun
katsklaw, could you post your .chk file maybe? Im having this problem too, cant get it fixed.

Thanks


What IRCd do you use?


UnrealIRCD
Title:
Post by: katsklaw on March 19, 2008, 03:47:38 AM
then you need to use the Unreal .chk file like I already suggested. It's not hard to edit for Anope.
Title:
Post by: TommyGun on March 19, 2008, 09:54:11 PM
I know, but im not really sure about the edits. Is this correct?

Code: [Select]
#!/bin/sh

# The path to the services binary
ircdexe="/home/tommygun/services"

# The path to the services pid file
ircdname="/home/tommygun/services/services.pid"

########## you probably don't need to change anything below here ##########
if test -r $ircdname; then
  # there is a pid file -- is it current?
  ircdpid=`cat $ircdname`
  if `kill -CHLD $ircdpid >/dev/null 2>&1`; then
    # it's still going
    # back out quietly
    exit 0
  fi
  echo "Anope Crontab notice:"
  echo ""
  echo "Stale $ircdname file (erasing it)"
  rm -f $ircdname
fi
echo ""
echo "Couldn't find services running.  Reloading it..."
echo ""
$ircdexe
Title:
Post by: Jobe on March 20, 2008, 09:27:32 AM
TommyGun, for ircdexe it should be /home/tommygun/services/services assuming youre in /home/tommygun/services when you type ./services
Title:
Post by: TommyGun on March 21, 2008, 05:19:48 PM
Ah right, thanks. And how to get the pid back? Because now;

bash-3.00$ /home/tommygun/services/services.chk

Couldn't find services running. Reloading it...

IRC: [18:19] -irc.gamergun.com- *** Notice -- Link [@127.0.0.1.51132] cancelled, server services.gamergun.com already exists from services.gamergun.com
Title:
Post by: katsklaw on March 21, 2008, 06:51:05 PM
kill services then start services
Title:
Post by: TommyGun on March 21, 2008, 08:20:19 PM
Seems to work now... hope it will stay that way, lol

Thanks guys
Title:
Post by: Kreon on March 21, 2008, 10:48:36 PM
An unrealircd crontab script isnt as good as it could be thought.
i.e., if an operation system fails for some reason, and goes for reboot, pidfile isnt erased and if some process during startup will retake the same PID as services had before, then services would not start at all.
In that script only existance of the PID listed in services.pid is checked, and no check is done upon what process do that PID has.
This is really possible when services right before the system fail were started at system boot, so they have low numbers in PID.
Title:
Post by: TommyGun on March 22, 2008, 11:25:39 AM
So... you can write another script? ;)