开发者

Apache2, Git, Capistrano & Rails - creating symlinks

I'm sort of stuck with adding symlinks to my app on the server. I currently have the following in .gitignore:

/non-public/system/uploads/*

I basically don't want Git to store the contents of the upload directory. So far so good.

On my server, inside my deploy.rb, I have the following:

namespace :customs do
  task :symlink, :roles => :app do
    run <<-CMD
      ln -nfs #{shared_path}/system/uploads #{release_path}/non-public/system/uploads
    CMD
  end
end

after "deploy:symlink","customs:symlink"
after "deploy", "deploy:cleanup"

I want to create a symlink after each deployment for the uploads directory, but I keep getting a failed error m开发者_StackOverflow社区essage because the non-public/system/uploads directory doesn't exist in the git repository in the first place.

I've verified this by taking a look at the repository, and the structure /non-public/system/uploads doesn't exist because I have that set in .gitignore to ignore it.

I've looked at the Git wiki and it doesn't track directories, so I must be missing something. How do other developers symlink the uploads directory with their server?


What I'll usually do on my cap deploys is to create the directories, by doing a basic

set :deploy_to, "/this/dir"

run "mkdir -p #{deploy_to}/then/more/dirs"

after "deploy:symlink"

namespace :deploy....
  ....
  ....

then provide the run code to do some symlinks either on an after or whatever. This probably not optimal for all situations, but for the simple stuff it usually gets the job done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜