How to compact buckets?
mrlightful
HOBBYOP

a month ago

PowerSync documentation suggests compacting buckets on a daily cron job by running a docker image command. How would I accomplish it in Railway?

Solved

1 Replies

michaelbarnes
PRO

a month ago

Hey there, great question. Here is what is needed:

1. Create a new service in your Railway project using the same PowerSync Docker image (journeyapps/powersync-service)

2. IMPORTANT: Override the start command to: /bin/sh -c "exec node service/lib/entry.js compact"

3. In the service's Settings, set the Cron Schedule field — e.g. 0 3 * * * (daily at 3am UTC)

4. Ensure the service shares the same environment variables as your main PowerSync service (POWERSYNC_CONFIG_B64 and PS_POSTGRES_BUCKET_URL)

Note: The deployment on the new service created in your project will be marked as crashed with errors along the line of:

Attempted to substitute environment variable "PS_AUTH_JWKS" which is undefined. Set this variable on the environment. Attempted to substitute environment variable "PS_AUTH_AUD" which is undefined. Set this variable on the environment.

This is not such a big issue because we you don't want the service to start another PowerSync instance (replicator + API), you only want the new service to run the compact command on a schedule on the service.

When the CRON JOB starts it will use the correct command to call the compact function on the container and then the CRON run should pass. You can check the Cron Runs tab to view the history.

We'll also update the template to include this, thanks for bringing this up.


Status changed to Awaiting User Response Railway 30 days ago


Railway
BOT

23 days ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 23 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...