以前就用 whenever + backup 备份,貌似没什么问题。 这次服务器迁移,就想着要不把 whenever 与 capistrano 3 结合,可是一键部署的时候出错了,错误信息摘要如下
INFO : Running ~/.rvm/bin/rvm 2.2.0 do bundle exec whenever --update-crontab weekly_production --set environment=production --roles=app,web,db as deploy@xxx
DEBUG: Command: cd /app/www/weekly/releases/20150408084632 && ~/.rvm/bin/rvm 2.2.0 do bundle exec whenever --update-crontab weekly_production --set environment=production --roles=app,web,db
DEBUG .../whenever-0.9.4/lib/whenever/numeric_seconds.rb:12:in `gsub'
DEBUG invalid byte sequence in US-ASCII (ArgumentError)
DEBUG
DEBUG from .../whenever-0.9.4/lib/whenever/numeric_seconds.rb:12:in `process_string'
DEBUG from .../whenever-0.9.4/lib/whenever/job_list.rb:25:in `initialize'
DEBUG from .../whenever-0.9.4/lib/whenever.rb:10:in `new'
DEBUG from .../whenever-0.9.4/lib/whenever.rb:10:in `cron'
DEBUG from .../whenever-0.9.4/lib/whenever/command_line.rb:54:in `whenever_cron'
DEBUG from .../whenever-0.9.4/lib/whenever/command_line.rb:106:in `updated_crontab'
DEBUG from .../whenever-0.9.4/lib/whenever/command_line.rb:35:in `run'
DEBUG from .../whenever-0.9.4/lib/whenever/command_line.rb:6:in `execute'
DEBUG from .../whenever-0.9.4/bin/whenever:41:in `<top (required)>'
DEBUG from /app/www/weekly/shared/bundle/ruby/2.2.0/bin/whenever:23:in `load'
DEBUG from /app/www/weekly/shared/bundle/ruby/2.2.0/bin/whenever:23:in `<main>'
(Backtrace restricted to imported tasks)
cap aborted!
Tasks: TOP => whenever:update_crontab
然后我就看了看,貌似系统是 utf8 的啊,哪来的 US-ASCII?
$locale
LANG=en_US.UTF-8
LANGUAGE=en_US:
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
到底是哪里出错了?没想明白……
后来看了看,想是不是
LANGUAGE=en_US:
LC_CTYPE=zh_CN.UTF-8
两句有冲突。本来我是改为用 en_US.UTF-8 的,但不知道为什么说 LC_CTYPE 修改不了。 我就决定要不全改为 zh_CN.UTF-8 吧。
修改 locale 文件
sudo vi /etc/default/locale
修改为:
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:"
执行 shell 命令
export LANGUAGE=zh_CN.UTF-8
export LANG=zh_CN.UTF-8
sudo locale-gen zh_CN.UTF-8
检查
$ locale
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
再 capistrano 一键部署就成功了