Post Deploy Configuration

Ruby Post-Deploy Configuration

Ruby applications often require additional tasks after deployment, such as database migrations, token generation, or loading default data. The platform automates these tasks through a project-level rake_deploy file.

Post-Deploy Configuration Overview

The platform can execute Rake tasks after an application is deployed. This is useful for finalizing complex application setup, running additional application-specific actions, or applying configuration tasks such as db:migrate.

File namerake_deploy
File locationThe root directory of the deployed Ruby application.
Command formatOne Rake command per line, without the leading rake keyword.
Execution orderCommands are executed sequentially from the first line to the last.
Execution triggerThe file is processed after each Apache or NGINX service restart.
Automatic cleanupThe file is deleted after all commands complete successfully.

Create the rake_deploy File

1

Open the application root

Open the configuration-file manager or connect to the Ruby application server through SSH, then navigate to the project root directory.

2

Create rake_deploy

Create a new text file named exactly rake_deploy.

3

Add the required commands

Enter each Rake task on a separate line.

$COMMAND_NAME_1
$COMMAND_NAME_2
...
$COMMAND_NAME_N
i

Do not include the rake prefix

The file should contain only the task names. The platform automatically adds rake when executing each line.

How Commands Are Executed

For the previous rake_deploy example, the platform runs:

rake $COMMAND_NAME_1
rake $COMMAND_NAME_2
...
rake $COMMAND_NAME_N
  • The first command must complete before the next command starts.
  • The commands are triggered when the Apache or NGINX service restarts.
  • After successful execution, the rake_deploy file is removed automatically.
  • For different tasks on the next deployment, create a new rake_deploy file containing the new command list.

Repeatable deployment tasks

Keep the file in the deployment package or generate it during the release process when the same post-deployment tasks must be performed after every deployment.

Redmine Example

For a Redmine deployment, the rake_deploy file can contain:

generate_secret_token
db:migrate
redmine:load_default_data

The platform executes the tasks as follows:

rake generate_secret_token
rake db:migrate
rake redmine:load_default_data
i

Freeze gems

To freeze gems, add gems:unpack as another command in the rake_deploy file.

Review Execution Logs

The platform saves the output generated by each rake_deploy execution in a corresponding log file. Open the environment’s Logs view in the dashboard to review task output and troubleshoot failures.

  • Confirm that every task started and completed.
  • Check database connection or migration errors.
  • Review missing-gem or dependency messages.
  • Confirm that the rake_deploy file was removed after successful completion.

Expected Result

After the Apache or NGINX service restarts, the platform executes each task listed in rake_deploy sequentially through Rake. The output is written to the dashboard logs, and the file is deleted automatically when all commands finish successfully.

Important Notes

  • Place rake_deploy in the application root directory.
  • Add one task per line.
  • Do not include the rake prefix in the file.
  • Commands run sequentially after an Apache or NGINX restart.
  • The file is removed only after successful execution.
  • Create a new file when different commands are needed for a later deployment.
  • Review the Logs view when a task does not complete.

Common Issues and Solutions

Tasks do not runCheck that the file is named exactly rake_deploy, is stored in the application root, and the Apache or NGINX service was restarted.
A task runs twiceVerify that the same action is not also executed by another deployment hook or startup script.
The file is not removedOne or more commands probably failed. Review the corresponding dashboard log.
Database migration failsCheck database credentials, environment mode, connectivity, schema state, and migration dependencies.
Gem-related task failsReview the Gemfile, Bundler output, selected Ruby version, and native extension requirements.