You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org
Wm-bot: Difference between revisions
imported>Petrb |
imported>Billinghurst |
||
(10 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
'''[[m:wm-bot|wm-bot]]''' is an IRC bot that participates in several developer-related wiki channels. | '''[[m:wm-bot|wm-bot]]''' is an IRC bot that participates in several developer-related wiki channels. wm-bot is currently running simultaneously on libera.chat | ||
== All stars team == | == All stars team == | ||
These folks are currently operating the bot, please insert your name if you are one of us: | These folks are currently operating the bot, please insert your name if you are one of us: | ||
* Petr Bena [[User:Petrb]] '''petan''' on | * Petr Bena [[User:Petrb]] '''petan''' on Libera.chat (server access) | ||
* Billinghurst [[User:Billinghurst]] '''sDrewth''' on Libera.chat (server access) | |||
* Billinghurst [[User:Billinghurst]] '''sDrewth''' on | * Matthew Bowker [[User:Matthewrbowker]] '''Matthew_''' on Libera.chat (server access) | ||
* | * MacFan4000 [[User:MacFan4000]] ''' MacFan4000 ''' on Libera.chat (server access) | ||
* | * [[User:Legoktm]] '''legoktm''' on Libera.chat (server access) | ||
* | |||
== Where is it == | == Where is it == | ||
Instance wm-bot.wm-bot. | Instance wm-bot.wm-bot.eqiad1.wikimedia.cloud, you need root to operate the bot. | ||
/opt/wm-bot | * /opt/wm-bot (freenode, historical, not in operation) | ||
* /opt/wm-bot-lib (libera) | |||
== How does it work == | == 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. | Bot is using external bouncers (AKA IO buffer servers in its configuration). 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. | 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. | ||
<pre> | |||
┌──────────────────────┐ | |||
│ │ | |||
│ Libera │ | |||
│ │ | |||
└──────────────────────┘ | |||
▲ ▲ | |||
│ │ | |||
│ │ | |||
│ │ | |||
│ │ | |||
┌───┴───┐ ┌───┴───┐ | |||
│ │ │ │ | |||
│ BNC 1 │ │ BNC 2 │ | |||
│ │ │ │ | |||
└───────┘ └───────┘ | |||
▲ ▲ | |||
│ │ | |||
└──────┐┌──────┘ | |||
││ | |||
┌───────┴┴───────┐ | |||
│ │ | |||
│ Bot core │ | |||
│ │ | |||
└─┬────────────┬─┘ | |||
│ │ | |||
│ │ | |||
│ │ | |||
│ │ | |||
│ │ | |||
▼ ▼ | |||
┌───────┐ ┌────────────┐ | |||
│ │ │ │ | |||
│ MySQL │ │ PostgreSQL │ | |||
│ │ │ │ | |||
└───────┘ └────────────┘ | |||
</pre> | |||
== Paths == | == Paths == | ||
=== Freenode (historical, not in operation) === | |||
{| class="wikitable" | {| class="wikitable" | ||
Line 37: | Line 78: | ||
! IRC Logs | ! IRC Logs | ||
| /var/www/html/logs | | /var/www/html/logs | ||
|} | |||
=== Libera === | |||
{| class="wikitable" | |||
|- | |||
! rowspan=2 | Binaries | |||
| /opt/wm-bot-lib/wmib.exe - core | |||
|- | |||
| /opt/wm-bot-lib/bouncer.exe | |||
|- | |||
! Configuration | |||
| /opt/wm-bot-lib/configuration | |||
|- | |||
! Logs | |||
| /opt/wm-bot-lib/*.log | |||
|- | |||
! IRC Logs | |||
| /var/www/libera/logs | |||
|} | |} | ||
== How to start the bot == | == 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 | '''IMPORTANT''': If the server has crashed and bot wasn't properly shut down you have to remove all pid files using | ||
sudo rm -iv / | sudo rm -iv /opt/wm-bot-lib/*.pid | ||
If bot isn't running you can start it using | If bot isn't running you can start it using | ||
sudo service wm-bot start | sudo service wm-bot-lib start | ||
=== Troubleshooting === | === Troubleshooting === | ||
Line 52: | Line 112: | ||
If nothing is running, it should be ok, if some processes are there, kill them | If nothing is running, it should be ok, if some processes are there, kill them | ||
* Ensure there are no *pid files in / | * Ensure there are no *pid files in /opt/wm-bot-lib | ||
* Make sure there is no restart.lock file | * Make sure there is no restart.lock file | ||
* There must be only 1 instance of core (restart.sh) running in same time | * There must be only 1 instance of core (restart.sh) running in same time | ||
tail / | tail /opt/wm-bot-lib/wmib.log is your friend | ||
== How to restart the bot core (fixes most problems) == | == 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: | 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 / | * tail /opt/wm-bot-lib/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 | * join #wm-bot | ||
* type @restart | * type @restart | ||
Line 80: | Line 140: | ||
This command will also restart the bot, but it may not give it enough time to properly shut down (bot's proper shut down takes about 10 seconds) | This command will also restart the bot, but it may not give it enough time to properly shut down (bot's proper shut down takes about 10 seconds) | ||
sudo service wm-bot restart | sudo service wm-bot-lib restart | ||
== How to fix 1 or more disconnected instances == | == How to fix 1 or more disconnected instances == | ||
Secret password is in /opt/wm-bot/configuration/admins (username is root) it's on first row third column | Secret password is in /opt/wm-bot-lib/configuration/admins (username is root) it's on first row third column | ||
* Connect to local sysadmin console | * Connect to local sysadmin console (noting that the bot core needs to be running) | ||
$ telnet localhost | $ telnet localhost 2820 | ||
* Now enter the username (root) and password | * Now enter the username (root) and password | ||
Line 107: | Line 167: | ||
kill wm-bot | 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:// | 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://wm-bot.wmcloud.org/dump/systemdata.htm | ||
Once you kill that, you need start it again: | Once you kill that, you need start it again: | ||
Line 123: | Line 183: | ||
* Chmod the logfile with 000 (bot won't be able to write) | * Chmod the logfile with 000 (bot won't be able to write) | ||
* Fix it and change the permissions back | * Fix it and change the permissions back | ||
* Connect to SQL database, using password in the <code>pg_pass=</code> variable in the <code>/opt/wm-bot/configuration/wmib.conf</code> file: | * Connect to SQL database, using password in the <code>pg_pass=</code> variable in the <code>/opt/wm-bot-lib/configuration/wmib.conf</code> file: | ||
'''IMPORTANT''': PostgreSQL doesn't have any decent backups yet, so please be careful, damaging DB may not be reversible | '''IMPORTANT''': PostgreSQL doesn't have any decent backups yet, so please be careful, damaging DB may not be reversible | ||
<pre> | <pre> | ||
root@wm-bot2:~# psql -h wm-bot-pg2 -U | root@wm-bot2:~# psql -h wm-bot-pg2 -U wm_bot_lib | ||
# Removing single line - this query may take minutes | # Removing single line - this query may take minutes | ||
Line 135: | Line 195: | ||
* Drop the logs for the given channel (complete removal): | * Drop the logs for the given channel (complete removal): | ||
<pre> | <pre> | ||
wm_bot_lib=> delete from logs where channel='#mychannel'; | |||
</pre> | </pre> | ||
Line 142: | Line 202: | ||
that will recompile all source code in ../wikimedia-bot stop the bot, replace the binaries and start the bot | that will recompile all source code in ../wikimedia-bot stop the bot, replace the binaries and start the bot | ||
== How to change the nickname of bot == | |||
Nickname that is chosen when bouncer reconnects to network is defined in configuration file (configuration/wmib.conf), each instance may have completely different nickname. If you want to change it only temporarily, or fix it back (in case nick is taken, bot will append random number to nick), you have two options: | |||
* Wait - bot will automatically regain its hardcoded nick, it will perform check during periodic network resync, which happens about once a day (((Configuration.Channels.Count * 2000) + 80000) seconds to be precise). | |||
* Fix it via telnet: | |||
<pre> | |||
petrb@wm-bot:~$ telnet localhost 2820 | |||
Trying ::1... | |||
Trying 127.0.0.1... | |||
Connected to localhost. | |||
Escape character is '^]'. | |||
Enter username: | |||
Enter password: | |||
Successfuly logged in to wm-bot, I have 1 users logged in | |||
send wm-bot NICK wm-bot | |||
send wm-bot2 NICK wm-bot2 | |||
quit | |||
</pre> | |||
Password can be found in configuration/admins file | |||
== Backups == | |||
Are done using rsnapshot, see /etc/rsnapshot.conf, everything is stored under FS /backups, intervals are defined in /etc/cron.d/rsnapshot | |||
==See also== | |||
* [[XmlRcs]] utilised by Wm-bot for recent changes components—may need a restart. | |||
[[Category:Bots]] | [[Category:Bots]] |
Revision as of 03:43, 13 November 2021
wm-bot is an IRC bot that participates in several developer-related wiki channels. wm-bot is currently running simultaneously on libera.chat
All stars team
These folks are currently operating the bot, please insert your name if you are one of us:
- Petr Bena User:Petrb petan on Libera.chat (server access)
- Billinghurst User:Billinghurst sDrewth on Libera.chat (server access)
- Matthew Bowker User:Matthewrbowker Matthew_ on Libera.chat (server access)
- MacFan4000 User:MacFan4000 MacFan4000 on Libera.chat (server access)
- User:Legoktm legoktm on Libera.chat (server access)
Where is it
Instance wm-bot.wm-bot.eqiad1.wikimedia.cloud, you need root to operate the bot.
- /opt/wm-bot (freenode, historical, not in operation)
- /opt/wm-bot-lib (libera)
How does it work
Bot is using external bouncers (AKA IO buffer servers in its configuration). 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.
┌──────────────────────┐ │ │ │ Libera │ │ │ └──────────────────────┘ ▲ ▲ │ │ │ │ │ │ │ │ ┌───┴───┐ ┌───┴───┐ │ │ │ │ │ BNC 1 │ │ BNC 2 │ │ │ │ │ └───────┘ └───────┘ ▲ ▲ │ │ └──────┐┌──────┘ ││ ┌───────┴┴───────┐ │ │ │ Bot core │ │ │ └─┬────────────┬─┘ │ │ │ │ │ │ │ │ │ │ ▼ ▼ ┌───────┐ ┌────────────┐ │ │ │ │ │ MySQL │ │ PostgreSQL │ │ │ │ │ └───────┘ └────────────┘
Paths
Freenode (historical, not in operation)
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 |
Libera
Binaries | /opt/wm-bot-lib/wmib.exe - core |
---|---|
/opt/wm-bot-lib/bouncer.exe | |
Configuration | /opt/wm-bot-lib/configuration |
Logs | /opt/wm-bot-lib/*.log |
IRC Logs | /var/www/libera/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 /opt/wm-bot-lib/*.pid
If bot isn't running you can start it using
sudo service wm-bot-lib 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 /opt/wm-bot-lib
- Make sure there is no restart.lock file
- There must be only 1 instance of core (restart.sh) running in same time
tail /opt/wm-bot-lib/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 /opt/wm-bot-lib/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 stop_all.sh
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 -15).
This command will also restart the bot, but it may not give it enough time to properly shut down (bot's proper shut down takes about 10 seconds)
sudo service wm-bot-lib restart
How to fix 1 or more disconnected instances
Secret password is in /opt/wm-bot-lib/configuration/admins (username is root) it's on first row third column
- Connect to local sysadmin console (noting that the bot core needs to be running)
$ telnet localhost 2820
- Now enter the username (root) and password
- Check the status (info / help)
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://wm-bot.wmcloud.org/dump/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 database, using password in the
pg_pass=
variable in the/opt/wm-bot-lib/configuration/wmib.conf
file:
IMPORTANT: PostgreSQL doesn't have any decent backups yet, so please be careful, damaging DB may not be reversible
root@wm-bot2:~# psql -h wm-bot-pg2 -U wm_bot_lib # Removing single line - this query may take minutes > select * from logs where contents like '%text_you_search_for%'; > update logs set contents = 'redacted' where id = number_you_got_from_previous_query;
- Drop the logs for the given channel (complete removal):
wm_bot_lib=> delete from logs where channel='#mychannel';
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
How to change the nickname of bot
Nickname that is chosen when bouncer reconnects to network is defined in configuration file (configuration/wmib.conf), each instance may have completely different nickname. If you want to change it only temporarily, or fix it back (in case nick is taken, bot will append random number to nick), you have two options:
- Wait - bot will automatically regain its hardcoded nick, it will perform check during periodic network resync, which happens about once a day (((Configuration.Channels.Count * 2000) + 80000) seconds to be precise).
- Fix it via telnet:
petrb@wm-bot:~$ telnet localhost 2820 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Enter username: Enter password: Successfuly logged in to wm-bot, I have 1 users logged in send wm-bot NICK wm-bot send wm-bot2 NICK wm-bot2 quit
Password can be found in configuration/admins file
Backups
Are done using rsnapshot, see /etc/rsnapshot.conf, everything is stored under FS /backups, intervals are defined in /etc/cron.d/rsnapshot
See also
- XmlRcs utilised by Wm-bot for recent changes components—may need a restart.