Skip to content

Instantly share code, notes, and snippets.

@000yesnt
Last active February 7, 2025 10:53
Show Gist options
  • Save 000yesnt/663906b26d53acde72f46f1be3c334b7 to your computer and use it in GitHub Desktop.
Save 000yesnt/663906b26d53acde72f46f1be3c334b7 to your computer and use it in GitHub Desktop.
Get rid of the CPU-intensive Seafile send_file_updates background task.

Disabling send_file_updates

This task is meant to send emails to users about file changes. There are many cases (such as single user deployments) where this is unnecessary. Although it's part of the seafevents Seafile component, it cannot be disabled, even through seafile.conf. In low end hardware, it consumes a lot of CPU, making Seafile as a whole feel sluggish.

To disable it, you'll need to overwrite some Seafile code and write a custom Dockerfile to apply it.

1. Identifying the location

The task code is at /opt/seafile/seafile-server-<version>/pro/python/seafevents/tasks/file_updates_sender.py. We need the value for <version>.

Enter the Seafile container with docker compose exec -it seafile bash, then run ls. Example output on a Seafile 12.0.7 container:

root@29eaeaeb36e1:/opt/seafile# ls
ccnet  conf  logs  pids  pro-data  seafile-data  seafile-server-12.0.7  seafile-server-latest  seahub-data

The folder we're interested in is seafile-server-12.0.7 - seafile-server-latest is a symlink to this folder. Therefore, the task is at /opt/seafile/seafile-server-12.0.7/pro/python/seafevents/tasks/file_updates_sender.py

Warning

The version in the folder name will be different depending on your Seafile version. It may also change between updates, so be sure to double-check your changes every time you upgrade.

2. Patching

Create a folder named patches - this is where we'll store our patch. Copy the file_updates_sender.py to this folder:

docker compose cp seafile:/opt/seafile/seafile-server-<version>/pro/python/seafevents/tasks/file_updates_sender.py patches/file_updates_sender.py

Open the file in the editor of your choice. Find the following lines:

    def start(self):
        logging.info('Start file updates sender, interval = %s sec', self._interval)

        FileUpdatesSenderTimer(self._interval, self._logfile).start()

Comment out the last line, like this:

    def start(self):
        logging.info('Start file updates sender, interval = %s sec', self._interval)

        #FileUpdatesSenderTimer(self._interval, self._logfile).start()

Save the edited file.

3. Dockerfile

In the same location as your Seafile docker-compose.yml, create a new file named Dockerfile. Put the following in it:

FROM seafileltd/seafile-mc:<image-version>

COPY patches/file_updates_sender.py /opt/seafile/seafile-server-<version>/pro/python/seafevents/tasks/file_updates_sender.py

Replace:

  • <image-version> with the Seafile version set in docker-compose.yml (or in Seafile 12.0+, .env). Example: 12.0-latest
  • <version> with the folder version you found earlier.

To make Docker use it, open your docker-compose.yml and look for where the seafile service is defined:

  seafile:
    image: seafileltd/seafile-mc:11.0-latest
    container_name: seafile
  # etc...

Change the image line to:

  seafile:
    build: .
    container_name: seafile
  # etc...

Now run docker compose up --build -d seafile, and you're done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment