我想在服务器上启动应用程序时运行一些命令。
所以,我在 config / deploy.rb :
中编写了这样的脚本desc "Start sphinx"
task :start_sphinx, :roles => :app do
run "cd #{current_path} && bundle install --without development test && bundle install --deployment && chmod 777 -R #{current_path}/tmp/ && rake thinking_sphinx:configure && rake thinking_sphinx:start"
end
但是当我打印
$ cap deploy
它不起作用。所以,请告诉我有什么问题!
这是来自终端的日志:
$ cap deploy
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git://github.com/Loremaster/sample_app.git master"
command finished in 367ms
* executing "if [ -d /vol/www/apps/ror_tutorial/shared/cached-copy ]; then cd /vol/www/apps/ror_tutorial/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard b5073e9b9aefd98873489bb6e97249593ea1a978 && git clean -q -d -x -f; else git clone -q git://github.com/Loremaster/sample_app.git /vol/www/apps/ror_tutorial/shared/cached-copy && cd /vol/www/apps/ror_tutorial/shared/cached-copy && git checkout -q -b deploy b5073e9b9aefd98873489bb6e97249593ea1a978; fi"
servers: ["188.127.224.136"]
Password:
[188.127.224.136] executing command
command finished in 3070ms
copying the cached version to /vol/www/apps/ror_tutorial/releases/20120125165835
* executing "cp -RPp /vol/www/apps/ror_tutorial/shared/cached-copy /vol/www/apps/ror_tutorial/releases/20120125165835 && (echo b5073e9b9aefd98873489bb6e97249593ea1a978 > /vol/www/apps/ror_tutorial/releases/20120125165835/REVISION)"
servers: ["188.127.224.136"]
[188.127.224.136] executing command
command finished in 49970ms
* executing `deploy:finalize_update'
* executing "chmod -R g+w /vol/www/apps/ror_tutorial/releases/20120125165835"
servers: ["188.127.224.136"]
[188.127.224.136] executing command
command finished in 1023ms
* executing "rm -rf /vol/www/apps/ror_tutorial/releases/20120125165835/log /vol/www/apps/ror_tutorial/releases/20120125165835/public/system /vol/www/apps/ror_tutorial/releases/20120125165835/tmp/pids &&\\\n mkdir -p /vol/www/apps/ror_tutorial/releases/20120125165835/public &&\\\n mkdir -p /vol/www/apps/ror_tutorial/releases/20120125165835/tmp &&\\\n ln -s /vol/www/apps/ror_tutorial/shared/log /vol/www/apps/ror_tutorial/releases/20120125165835/log &&\\\n ln -s /vol/www/apps/ror_tutorial/shared/system /vol/www/apps/ror_tutorial/releases/20120125165835/public/system &&\\\n ln -s /vol/www/apps/ror_tutorial/shared/pids /vol/www/apps/ror_tutorial/releases/20120125165835/tmp/pids"
servers: ["188.127.224.136"]
[188.127.224.136] executing command
command finished in 150ms
* executing "find /vol/www/apps/ror_tutorial/releases/20120125165835/public/images /vol/www/apps/ror_tutorial/releases/20120125165835/public/stylesheets /vol/www/apps/ror_tutorial/releases/20120125165835/public/javascripts -exec touch -t 201201251659.26 {} ';'; true"
servers: ["188.127.224.136"]
[188.127.224.136] executing command
** [out :: 188.127.224.136] find: `/vol/www/apps/ror_tutorial/releases/20120125165835/public/images': No such file or directory
** [out :: 188.127.224.136] find: `/vol/www/apps/ror_tutorial/releases/20120125165835/public/stylesheets': No such file or directory
** [out :: 188.127.224.136] find: `/vol/www/apps/ror_tutorial/releases/20120125165835/public/javascripts': No such file or directory
command finished in 566ms
* executing `deploy:symlink'
* executing "rm -f /vol/www/apps/ror_tutorial/current && ln -s /vol/www/apps/ror_tutorial/releases/20120125165835 /vol/www/apps/ror_tutorial/current"
servers: ["188.127.224.136"]
[188.127.224.136] executing command
command finished in 56ms
** transaction: commit
* executing `deploy:restart'
* executing "sudo -p 'sudo password: ' touch /vol/www/apps/ror_tutorial/current/tmp/restart.txt"
servers: ["188.127.224.136"]
[188.127.224.136] executing command
command finished in 163ms
答案 0 :(得分:3)
看起来你错过了回调。例如,如果您想在代码更新后运行脚本,则可以使用后回调,如
after "deploy:update_code", "start_sphinx"
有关回调的更多信息,请查看callbacks rdoc