1. ROR的一些常用命令,配置让他在适当的时机自动运行,并在log中提示
在开发过程中,何必一次次的去敲这些命令呢,而且还容易忘记,让脚本去做不省事。
编辑config.sh
cd ~
mkdir .inotify_job
vim config.sh
#! /bin/bash
inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e close_write /home/jimyjiang/console/config \
| while read date time dir file; do
cd /home/jimyjiang/console;
touch tmp/restart.txt;
echo "passenger restarted!" >> /opt/nginx/logs/error.log;
done
编辑frontend.sh
vim frontend.sh
#! /bin/bash
source /home/jimyjiang/.rvm/scripts/rvm
inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e close_write /home/jimyjiang/console/config/locales/frontend \
| while read date time dir file; do
if echo "${file}"|grep "\.yml"; then
# source /home/jimyjiang/.rvm/scripts/rvm
echo "${file} changed" >> /opt/nginx/logs/error.log;
cd /home/jimyjiang/console/;
echo "do rake command i18n:js:export;" >> /opt/nginx/logs/error.log;
`bundle exec rake i18n:js:export` >> /opt/nginx/logs/error.log;
echo "rake i18n:js:export is done" >> /opt/nginx/logs/error.log;
fi
done
编辑lib.sh
vim lib.sh
#! /bin/bash
inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e close_write /home/jimyjiang/console/lib \
| while read date time dir file; do
cd /home/jimyjiang/console;
touch tmp/restart.txt;
echo "passenger restarted!" >> /opt/nginx/logs/error.log;
done
编辑reload.sh
vim reload.sh
#! /bin/bash
inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e close_write /home/jimyjiang/console/tmp/restart.txt \
| while read date time dir file; do
echo "Start reload" >> /opt/nginx/logs/error.log;
curl http://dev.console.nirvanainfo.com/login >> /dev/null
echo "Reloaded!" >> /opt/nginx/logs/error.log;
done
编辑inmotify.sh
cd ~
vim inotify.sh
#! /bin/bash
`nohup bash /home/jimyjiang/.inotify_job/frontend.sh << /dev/null` &
`nohup bash /home/jimyjiang/.inotify_job/config.sh << /dev/null` &
`nohup bash /home/jimyjiang/.inotify_job/lib.sh << /dev/null` &
`nohup bash /home/jimyjiang/.inotify_job/reload.sh << /dev/null` &
执行:
su
bash inotify.sh