2012-07-29 27 views
0

我有這個PICE代碼deploy.rb文件:創建Capistrano的迪爾斯後部署

after :deploy do 
    run "if [ -d #{rails_root}/tmp/pids ]; then mkdir #{rails_root}/tmp/pids && chmod 0777 #{rails_root}/tmp/pids; fi" 
end 

有麻煩,你可以看到它@終端的屏幕截圖: enter image description here

同樣troube是與日誌目錄,但它只是從git回購(通過capistrano)克隆。當我克隆項目manualy - 日誌目錄運作良好。 enter image description here

兩個問題:

  1. 什麼的PID /日誌「目錄」,如果不是文件或目錄或其他什麼東西?
  2. 我該如何解決這個問題?

回答

1

幾個建議:

man test顯示

-d file  True if file exists and is a directory. 

所以你可能是說如果[! -d xxx/tmp/pids];

更容易試用,只是在一個臨時目錄中運行shell命令:

if [ ! -d xxx/tmp/pids ]; then mkdir xxx/tmp/pids && chmod 0777 xxx/tmp/pids; fi 

的mkdir失敗,如果迪爾斯進一步向上的路徑不存在 - 使用的mkdir -p

if [ ! -d xxx/tmp/pids ]; then mkdir -p xxx/tmp/pids && chmod 0777 xxx/tmp/pids; fi 

那應該做你想要的。

(截圖是非常難以破譯。如果你想上的文件類型的更多信息,請ls -l並願意在這裏複製的文本輸出不是顯示主要背景圖像的截圖...)