Skip to content

Publish populate

Intro

In production, with DBs with many articles, the wf:cms:publish:populate may need special considerations.

For PRO environments, this task should be ran as make publish-populate. This is a make task that automatically enables a PHP extension to allow sending multiple commands to Redis instead of sending them one by one.

The task runs wf:cms:publish:populate in multi mode, meaning the command, instead of actually running the commands against the Redis server, will only dump them into the /tmp/redis.buf file. After the Symfony command finishes, the make task pipes this file to the Redis server (cat /tmp/redis.buf | redis -h HOST --pipe)

Special considerations

  • Make sure redis-cli is available on the server where this task is being ran
  • Make sure redis-cli version installed on this server accepts the host argument (-h) by running redis-cli --help (version 2.4 supports it)
  • Some shells complain when running make publish-populate (./vendor/wfcms/cms-base-admin-bundle/Wf/Bundle/CmsBaseAdminBundle/Resources/bin/publish-populate: 7: ./vendor/wfcms/cms-base-admin-bundle/Wf/Bundle/CmsBaseAdminBundle/Resources/bin/publish-populate: [[: not found). It's safe to skip the make command and run it manually /bin/bash ./vendor/wfcms/cms-base-admin-bundle/Wf/Bundle/CmsBaseAdminBundle/Resources/bin/publish-populate

Slow piping to Redis

In some cases, piping the resulting .buf file to Redis can be very slow (this process should finish in less than a minute, even for considerably large DBs). This process can be sped up by taking the following approach:

  1. Make sure the redis-server is running on the same host as the CMS
  2. Change the tracking.redis.dsn to point to the local redis server (redis://127.0.0.1)
  3. Run the make task
  4. After it completes, save a dump of the local Redis: redis-cli save
  5. Check the location of the resulting dump.rdb file by checking redis-server conf (/etc/redis/redis.conf). The directory is taken from the dir config (e.g. /var/lib/redis), the name of the dumpfile is taken from dbfilename config (e.g. dump.rdb). So the final path to the dump file should be /var/lib/redis/dump.rdb
  6. Stop the PRO Redis server
  7. Copy this file to the PRO Redis server, to the path it uses for the dump, determined the same way as #5
  8. Start the PRO Redis server