Shannon
Shannon

Reputation: 2744

Symlink single file via Moonshine and/or Capistrano on production server

My application is set up with Moonshine which configures the server, then uses Capistrano to deploy. However, there are some files and directories that are not source control managed that shouldn't be deleted when a new deploy is made, nor should they come off my development machine.

In Moonshine's config/moonshine.yml file, there is the :app_symlinks area where symlinks are created to the shared folder on production. This works perfect for particular directories inside the public folder (like 'system')...however I need to do the same on individual files. For example, the sitemap.xml file that is automatically generated based on the database on production. Or the .htaccess file.

I tried to put individual files underneath :app_symlinks, but this didn't work. Is there a way in Moonshine to symlink individual files? Or alternatively, a way to do this in Capistrano (as that what Moonshine uses for deployment anyway).

Upvotes: 1

Views: 313

Answers (1)

Zepplock
Zepplock

Reputation: 29165

You can do the following in your deploy.rb:

desc "Link the file"
task :link_file do
  run "ln -nfs #{deploy_to}/shared/files/myfile #{release_path}/myfile"
end

and then add this task to: after "deploy", :link_file

Of course you'll need to create /shared/files directory manually, just once.

Upvotes: 2

Related Questions