2019-11-22 02:07:17 +01:00
|
|
|
# Troubleshooting and monitoring
|
2016-07-12 22:02:30 +02:00
|
|
|
|
2016-08-09 23:13:53 +02:00
|
|
|
Zulip uses [Supervisor](http://supervisord.org/index.html) to monitor
|
|
|
|
and control its many Python services. Read the next section, [Using
|
|
|
|
supervisorctl](#using-supervisorctl), to learn how to use the
|
|
|
|
Supervisor client to monitor and manage services.
|
|
|
|
|
|
|
|
If you haven't already, now might be a good time to read Zulip's [architectural
|
2019-09-30 19:37:56 +02:00
|
|
|
overview](../overview/architecture-overview.md), particularly the
|
2019-04-06 02:58:44 +02:00
|
|
|
[Components](../overview/architecture-overview.html#components) section. This will help you
|
2016-08-09 23:13:53 +02:00
|
|
|
understand the many services Zulip uses.
|
|
|
|
|
|
|
|
If you encounter issues while running Zulip, take a look at Zulip's logs, which
|
|
|
|
are located in `/var/log/zulip/`. That directory contains one log file for
|
|
|
|
each service, plus `errors.log` (has all errors), `server.log` (has logs from
|
|
|
|
the Django and Tornado servers), and `workers.log` (has combined logs from the
|
|
|
|
queue workers).
|
|
|
|
|
|
|
|
The section [troubleshooting services](#troubleshooting-services)
|
|
|
|
on this page includes details about how to fix common issues with Zulip services.
|
|
|
|
|
|
|
|
If you run into additional problems, [please report
|
|
|
|
them](https://github.com/zulip/zulip/issues) so that we can update
|
|
|
|
this page! The Zulip installation scripts logs its full output to
|
|
|
|
`/var/log/zulip/install.log`, so please include the context for any
|
|
|
|
tracebacks from that log.
|
|
|
|
|
|
|
|
## Using supervisorctl
|
|
|
|
|
|
|
|
To see what Zulip-related services are configured to
|
|
|
|
use Supervisor, look at `/etc/supervisor/conf.d/zulip.conf` and
|
|
|
|
`/etc/supervisor/conf.d/zulip-db.conf`.
|
|
|
|
|
|
|
|
Use the supervisor client `supervisorctl` to list the status of, stop, start,
|
|
|
|
and restart various services.
|
|
|
|
|
|
|
|
### Checking status with `supervisorctl status`
|
|
|
|
|
2020-10-23 02:43:28 +02:00
|
|
|
You can check if the Zulip application is running using:
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
2016-07-12 22:02:30 +02:00
|
|
|
supervisorctl status
|
|
|
|
```
|
|
|
|
|
2016-08-09 23:13:53 +02:00
|
|
|
When everything is running as expected, you will see something like this:
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```console
|
2021-06-11 22:50:53 +02:00
|
|
|
process-fts-updates RUNNING pid 11392, uptime 19:40:06
|
|
|
|
smokescreen RUNNING pid 3113, uptime 29 days, 21:58:32
|
|
|
|
teleport_node RUNNING pid 15683, uptime 3 days, 13:01:58
|
|
|
|
zulip-django RUNNING pid 11441, uptime 19:39:57
|
|
|
|
zulip-tornado RUNNING pid 11397, uptime 19:40:03
|
|
|
|
zulip_deliver_scheduled_emails RUNNING pid 10289, uptime 19:41:04
|
|
|
|
zulip_deliver_scheduled_messages RUNNING pid 10294, uptime 19:41:02
|
|
|
|
zulip-workers:zulip_events_deferred_work RUNNING pid 10314, uptime 19:41:00
|
|
|
|
zulip-workers:zulip_events_digest_emails RUNNING pid 10339, uptime 19:40:57
|
|
|
|
zulip-workers:zulip_events_email_mirror RUNNING pid 10751, uptime 19:40:52
|
|
|
|
zulip-workers:zulip_events_email_senders RUNNING pid 10769, uptime 19:40:49
|
|
|
|
zulip-workers:zulip_events_embed_links RUNNING pid 11035, uptime 19:40:46
|
|
|
|
zulip-workers:zulip_events_embedded_bots RUNNING pid 11139, uptime 19:40:43
|
|
|
|
zulip-workers:zulip_events_error_reports RUNNING pid 11154, uptime 19:40:40
|
|
|
|
zulip-workers:zulip_events_invites RUNNING pid 11261, uptime 19:40:36
|
|
|
|
zulip-workers:zulip_events_missedmessage_emails RUNNING pid 11346, uptime 19:40:21
|
|
|
|
zulip-workers:zulip_events_missedmessage_mobile_notifications RUNNING pid 11351, uptime 19:40:19
|
|
|
|
zulip-workers:zulip_events_outgoing_webhooks RUNNING pid 11358, uptime 19:40:17
|
|
|
|
zulip-workers:zulip_events_user_activity RUNNING pid 11365, uptime 19:40:14
|
|
|
|
zulip-workers:zulip_events_user_activity_interval RUNNING pid 11376, uptime 19:40:11
|
|
|
|
zulip-workers:zulip_events_user_presence RUNNING pid 11384, uptime 19:40:08
|
2016-08-09 23:13:53 +02:00
|
|
|
```
|
|
|
|
|
2019-11-22 18:59:43 +01:00
|
|
|
If you see any services showing a status other than `RUNNING`, or you
|
|
|
|
see an uptime under 5 seconds (which indicates it's crashing
|
|
|
|
immediately after startup and repeatedly restarting), that service
|
|
|
|
isn't running. If you don't see relevant logs in
|
|
|
|
`/var/log/zulip/errors.log`, check the log file declared via
|
|
|
|
`stdout_logfile` for that service's entry in
|
|
|
|
`/etc/supervisor/conf.d/zulip.conf` for details. Logs only make it to
|
|
|
|
`/var/log/zulip/errors.log` once a service has started fully.
|
|
|
|
|
2016-08-09 23:13:53 +02:00
|
|
|
### Restarting services with `supervisorctl restart all`
|
2016-07-12 22:02:30 +02:00
|
|
|
|
|
|
|
After you change configuration in `/etc/zulip/settings.py` or fix a
|
|
|
|
misconfiguration, you will often want to restart the Zulip application.
|
|
|
|
You can restart Zulip using:
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
2016-07-12 22:02:30 +02:00
|
|
|
supervisorctl restart all
|
|
|
|
```
|
|
|
|
|
2016-08-09 23:13:53 +02:00
|
|
|
### Stopping services with `supervisorctl stop all`
|
|
|
|
|
2016-07-12 22:02:30 +02:00
|
|
|
Similarly, you can stop Zulip using:
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
2016-07-12 22:02:30 +02:00
|
|
|
supervisorctl stop all
|
|
|
|
```
|
|
|
|
|
2021-04-16 07:46:05 +02:00
|
|
|
If you're looking to shut down the server, it is often better to run
|
|
|
|
`./scripts/stop-server`.
|
|
|
|
|
2016-08-09 23:13:53 +02:00
|
|
|
## Troubleshooting services
|
|
|
|
|
|
|
|
The Zulip application uses several major open source services to store
|
|
|
|
and cache data, queue messages, and otherwise support the Zulip
|
|
|
|
application:
|
2016-07-12 22:02:30 +02:00
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- PostgreSQL
|
|
|
|
- RabbitMQ
|
|
|
|
- Nginx
|
|
|
|
- Redis
|
|
|
|
- memcached
|
2016-07-12 22:02:30 +02:00
|
|
|
|
|
|
|
If one of these services is not installed or functioning correctly,
|
|
|
|
Zulip will not work. Below we detail some common configuration
|
|
|
|
problems and how to resolve them:
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- If your browser reports no webserver is running, that is likely
|
2016-07-12 22:02:30 +02:00
|
|
|
because nginx is not configured properly and thus failed to start.
|
|
|
|
nginx will fail to start if you configured SSL incorrectly or did
|
|
|
|
not provide SSL certificates. To fix this, configure them properly
|
|
|
|
and then run:
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
2016-07-12 22:02:30 +02:00
|
|
|
service nginx restart
|
|
|
|
```
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- If your host is being port scanned by unauthorized users, you may see
|
2017-02-25 03:41:30 +01:00
|
|
|
messages in `/var/log/zulip/server.log` like
|
2021-08-20 07:09:04 +02:00
|
|
|
```text
|
2017-02-25 03:41:30 +01:00
|
|
|
2017-02-22 14:11:33,537 ERROR Invalid HTTP_HOST header: '10.2.3.4'. You may need to add u'10.2.3.4' to ALLOWED_HOSTS.
|
|
|
|
```
|
|
|
|
Django uses the hostnames configured in `ALLOWED_HOSTS` to identify
|
|
|
|
legitimate requests and block others. When an incoming request does
|
|
|
|
not have the correct HTTP Host header, Django rejects it and logs the
|
|
|
|
attempt. For more on this issue, see the [Django release notes on Host header
|
|
|
|
poisoning](https://www.djangoproject.com/weblog/2013/feb/19/security/#s-issue-host-header-poisoning)
|
2019-11-22 02:07:17 +01:00
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- An AMQPConnectionError traceback or error running rabbitmqctl
|
2019-12-13 07:19:12 +01:00
|
|
|
usually means that RabbitMQ is not running; to fix this, try:
|
2021-08-20 07:09:04 +02:00
|
|
|
```bash
|
2019-12-13 07:19:12 +01:00
|
|
|
service rabbitmq-server restart
|
|
|
|
```
|
|
|
|
If RabbitMQ fails to start, the problem is often that you are using
|
|
|
|
a virtual machine with broken DNS configuration; you can often
|
|
|
|
correct this by configuring `/etc/hosts` properly.
|
|
|
|
|
2020-10-23 02:49:41 +02:00
|
|
|
### Restrict unattended upgrades
|
2019-12-02 19:43:33 +01:00
|
|
|
|
2021-08-10 07:55:12 +02:00
|
|
|
:::{important}
|
|
|
|
We recommend that you disable or limit Ubuntu's unattended-upgrades
|
|
|
|
to skip some server packages. With unattended upgrades enabled but
|
|
|
|
not limited, the moment a new PostgreSQL release is published, your
|
|
|
|
Zulip server will have its PostgreSQL server upgraded (and thus
|
|
|
|
restarted). If you do disable unattended-upgrades, do not forget to
|
|
|
|
regularly install apt upgrades manually!
|
|
|
|
:::
|
2019-12-02 19:43:33 +01:00
|
|
|
|
2020-10-26 22:27:53 +01:00
|
|
|
Restarting one of the system services that Zulip uses (PostgreSQL,
|
2020-10-23 02:43:28 +02:00
|
|
|
memcached, Redis, or Rabbitmq) will drop the connections that
|
2019-12-13 07:19:12 +01:00
|
|
|
Zulip processes have to the service, resulting in future operations on
|
|
|
|
those connections throwing errors.
|
|
|
|
|
|
|
|
Zulip is designed to recover from system service downtime by creating
|
|
|
|
new connections once the system service is back up, so the Zulip
|
|
|
|
outage will end once the system service finishes restarting. But
|
|
|
|
you'll get a bunch of error emails during the system service outage
|
|
|
|
whenever one of the Zulip server's ~20 workers attempts to access the
|
|
|
|
system service.
|
|
|
|
|
|
|
|
An unplanned outage will also result in an annoying (and potentially
|
|
|
|
confusing) trickle of error emails over the following hours or days.
|
|
|
|
These emails happen because a worker only learns its connection was
|
|
|
|
dropped when it next tries to access the connection (at which point
|
|
|
|
it'll send an error email and make a new connection), and several
|
|
|
|
workers are commonly idle for periods of hours or days at a time.
|
|
|
|
|
|
|
|
You can prevent this trickle when doing a planned upgrade by
|
|
|
|
restarting the Zulip server with
|
|
|
|
`/home/zulip/deployments/current/scripts/restart-server` after
|
2020-10-26 22:27:53 +01:00
|
|
|
installing system package updates to PostgreSQL, memcached,
|
2020-10-23 02:43:28 +02:00
|
|
|
RabbitMQ, or Redis.
|
2019-12-13 07:19:12 +01:00
|
|
|
|
2020-10-23 02:49:41 +02:00
|
|
|
You can ensure that the `unattended-upgrades` package never upgrades
|
|
|
|
PostgreSQL, memcached, Redis, or RabbitMQ, by configuring in
|
|
|
|
`/etc/apt/apt.conf.d/50unattended-upgrades`:
|
|
|
|
|
2021-08-20 07:09:04 +02:00
|
|
|
```text
|
2020-10-23 02:49:41 +02:00
|
|
|
// Python regular expressions, matching packages to exclude from upgrading
|
|
|
|
Unattended-Upgrade::Package-Blacklist {
|
|
|
|
"libc\d+";
|
|
|
|
"memcached$";
|
|
|
|
"nginx-full$";
|
|
|
|
"postgresql-\d+$";
|
|
|
|
"rabbitmq-server$";
|
|
|
|
"redis-server$";
|
|
|
|
"supervisor$";
|
|
|
|
};
|
|
|
|
```
|
2019-12-02 19:43:33 +01:00
|
|
|
|
2019-11-22 02:07:17 +01:00
|
|
|
## Monitoring
|
|
|
|
|
2019-11-22 18:59:43 +01:00
|
|
|
Chat is mission-critical to many organizations. This section contains
|
|
|
|
advice on monitoring your Zulip server to minimize downtime.
|
|
|
|
|
|
|
|
First, we should highlight that Zulip sends Django error emails to
|
|
|
|
`ZULIP_ADMINISTRATOR` for any backend exceptions. A properly
|
|
|
|
functioning Zulip server shouldn't send any such emails, so it's worth
|
|
|
|
reporting/investigating any that you do see.
|
|
|
|
|
|
|
|
Beyond that, the most important monitoring for a Zulip server is
|
|
|
|
standard stuff:
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- Basic host health monitoring for issues running out of disk space,
|
2019-11-22 18:59:43 +01:00
|
|
|
especially for the database and where uploads are stored.
|
2021-08-20 21:45:39 +02:00
|
|
|
- Service uptime and standard monitoring for the [services Zulip
|
2019-11-22 18:59:43 +01:00
|
|
|
depends on](#troubleshooting-services). Most monitoring software
|
2020-10-26 22:27:53 +01:00
|
|
|
has standard plugins for Nginx, PostgreSQL, Redis, RabbitMQ,
|
2020-10-23 02:43:28 +02:00
|
|
|
and memcached, and those will work well with Zulip.
|
2021-08-20 21:45:39 +02:00
|
|
|
- `supervisorctl status` showing all services `RUNNING`.
|
|
|
|
- Checking for processes being OOM killed.
|
2019-11-22 18:59:43 +01:00
|
|
|
|
|
|
|
Beyond that, Zulip ships a few application-specific end-to-end health
|
|
|
|
checks. The Nagios plugins `check_send_receive_time`,
|
|
|
|
`check_rabbitmq_queues`, and `check_rabbitmq_consumers` are generally
|
|
|
|
sufficient to point to the cause of any Zulip production issue. See
|
|
|
|
the next section for details.
|
|
|
|
|
|
|
|
### Nagios configuration
|
|
|
|
|
2019-11-22 02:07:17 +01:00
|
|
|
The complete Nagios configuration (sans secret keys) used to
|
2020-06-09 00:58:42 +02:00
|
|
|
monitor zulip.com is available under `puppet/zulip_ops` in the
|
2019-11-22 02:07:17 +01:00
|
|
|
Zulip Git repository (those files are not installed in the release
|
|
|
|
tarballs).
|
|
|
|
|
|
|
|
The Nagios plugins used by that configuration are installed
|
|
|
|
automatically by the Zulip installation process in subdirectories
|
|
|
|
under `/usr/lib/nagios/plugins/`. The following is a summary of the
|
2019-12-13 07:19:12 +01:00
|
|
|
useful Nagios plugins included with Zulip and what they check:
|
2019-11-22 02:07:17 +01:00
|
|
|
|
|
|
|
Application server and queue worker monitoring:
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- `check_send_receive_time`: Sends a test message through the system
|
2019-12-13 07:19:12 +01:00
|
|
|
between two bot users to check that end-to-end message sending
|
|
|
|
works. An effective end-to-end check for Zulip's Django and Tornado
|
|
|
|
systems being healthy.
|
2021-08-20 21:45:39 +02:00
|
|
|
- `check_rabbitmq_consumers` and `check_rabbitmq_queues`: Effective
|
2019-12-13 07:19:12 +01:00
|
|
|
checks for Zulip's RabbitMQ-based queuing systems being healthy.
|
2021-08-20 21:45:39 +02:00
|
|
|
- `check_worker_memory`: Monitors for memory leaks in queue workers.
|
2019-11-22 02:07:17 +01:00
|
|
|
|
|
|
|
Database monitoring:
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- `check_fts_update_log`: Checks whether full-text search updates are
|
2019-12-13 07:19:12 +01:00
|
|
|
being processed properly or getting backlogged.
|
2021-08-20 21:45:39 +02:00
|
|
|
- `check_postgres`: General checks for database health.
|
|
|
|
- `check_postgresql_backup`: Checks status of PostgreSQL backups.
|
|
|
|
- `check_postgresql_replication_lag`: Checks whether PostgreSQL streaming
|
2019-12-13 07:19:12 +01:00
|
|
|
replication is up to date.
|
2019-11-22 02:07:17 +01:00
|
|
|
|
|
|
|
Standard server monitoring:
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- `check_debian_packages`: Checks whether the system is behind on
|
2021-09-08 00:23:24 +02:00
|
|
|
`apt upgrade`.
|
2019-11-22 02:07:17 +01:00
|
|
|
|
|
|
|
If you're using these plugins, bug reports and pull requests to make
|
|
|
|
it easier to monitor Zulip and maintain it in production are
|
|
|
|
encouraged!
|
|
|
|
|
|
|
|
## Memory leak mitigation
|
|
|
|
|
2019-12-13 07:19:12 +01:00
|
|
|
As a measure to mitigate the potential impact of any future memory
|
|
|
|
leak bugs in one of the Zulip daemons, Zulip service automatically
|
|
|
|
restarts itself every Sunday early morning. See
|
|
|
|
`/etc/cron.d/restart-zulip` for the precise configuration.
|