Wm-bot

From Wikitech
Jump to: navigation, search

wm-bot is an IRC bot that participates in several developer-related wiki channels.

All stars team

These folks are currently operating the bot, please insert your name if you are one of us:

Where is it

Instance wm-bot2 (we can't rename it back to wm-bot) :( in project wm-bot, you need root to operate the bot.

/mnt/share/wm-bot

How does it work

Bot is using external bouncers. That means, you first start the bouncers, then you start restart script which keeps core running. The core is connected to bouncers, which are connected to network. In case you need to restart the core, bot stays connected to network.

This bot is using multiple instances but all are part of 1 huge system. The core handles all the instances but there is a bouncer for each of them.

Paths

Binaries /opt/wm-bot/wmib.exe - core
/opt/wm-bot/bouncer.exe
Configuration /opt/wm-bot/configuration
Logs /opt/wm-bot/*.log
IRC Logs /var/www/html/logs

How to start the bot

IMPORTANT: If the server has crashed and bot wasn't properly shut down you have to remove all pid files using

sudo rm -iv /mnt/share/wm-bot/*.pid

If bot isn't running you can start it using

sudo service wm-bot start

Troubleshooting

First of all, check what is already running:

ps -ef | grep wm-bot

If nothing is running, it should be ok, if some processes are there, kill them

  • Ensure there are no *pid files in /mnt/share/wm-bot
  • Make sure there is no restart.lock file
  • There must be only 1 instance of core (restart.sh) running in same time

tail /mnt/share/wm-bot/wmib.log is your friend

How to restart the bot core (fixes most problems)

This is what you should do if you just want to fix some bot issues, this will restart the core only, bot will stay connected to all channels and this process is painless and quick. Preferred:

  • tail /mnt/share/wm-bot/wmib.log there must be no critical errors! If you see that bot couldn't write log files etc, do not kill it, or these data will be permanently lost!
  • join #wm-bot
  • type @restart

If you get permission denied

You forgot to put your cloak to admins file, just ssh to wm-bot instance and kill process running as wm-bot called "mono wmib.exe". This process will restart itself when it crashes.

How to shutdown the bot

Complete shutdown

sudo service wm-bot stop

Core only

If you need to restart the bot because you changed the binaries and you need it to completely reload, you just need to execute "halt" or @restart in any channel. Keep in mind that doing restart after you changed the binary will likely fail (bot will crash instead of proper shutdown).

You can also shutdown the bot with signal (kill)

How to fix 1 or more disconnected instances

Secret password is in /mnt/share/wm-bot/password (username is root)

  • Connect to local sysadmin console

$ telnet localhost 2020

  • Now enter the username and password
  • Check the status
Successfuly logged in to wm-bot
info
Uptime: 0 days  0 hours since 7/18/2013 11:53:39 AM
Instances:
wm-bot channels: 50 connected: True working: True
wm-bot2 channels: 42 connected: True working: True

If you see that some instance is not working properly, no matter of status, shut it down:

kill wm-bot

Now, in second terminal, restart the corresponding bouncer, the bouncer is process bouncer.exe with parameter that correspond to broken instance, for example for wm-bot it's bouncer.exe 6667, list of all bouncers can be found at http://bots.wmflabs.org/~wm-bot/db/systemdata.htm

Once you kill that, you need start it again:

nohup mono bouncer.exe 6667 &

Once the bouncer is running again you need to connect bot to it, type this in system console:

conn wm-bot

How to change the logs

Recommended: In case you want to change logs, you must disable bot for that moment.

  • Chmod the logfile with 000 (bot won't be able to write)
  • Fix it and change the permissions back
  • Connect to sql (sudo su and then type mysql)
  • delete from wmib.logs where channel='<channel>';

How to patch the bot

sudo ./easydeploy.sh

that will recompile all source code in ../wikimedia-bot stop the bot, replace the binaries and start the bot