Ruby on rails: erinevus redaktsioonide vahel
Allikas: Kuutõrvaja
Mine navigeerimisribaleMine otsikasti
Resümee puudub |
Resümee puudub |
||
| 35. rida: | 35. rida: | ||
start_mongrel | start_mongrel | ||
#!/usr/local/bin/bash | #!/usr/local/bin/bash | ||
USER="root" | USER="root" | ||
GROUP="wheel" | GROUP="wheel" | ||
case $1 in | case $1 in | ||
start) | |||
/usr/local/bin/mongrel_rails start -d --user $USER --group $GROUP -p 8001 -a 127.0.0.1 -P rails-8001.pid | |||
/usr/local/bin/mongrel_rails start -d --user $USER --group $GROUP -p 8002 -a 127.0.0.1 -P rails-8002.pid | |||
/usr/local/bin/mongrel_rails start -d --user $USER --group $GROUP -p 8003 -a 127.0.0.1 -P rails-8003.pid | |||
;; | |||
restart) | |||
/usr/local/bin/mongrel_rails restart -P rails-8001.pid | |||
/usr/local/bin/mongrel_rails restart -P rails-8002.pid | |||
/usr/local/bin/mongrel_rails restart -P rails-8003.pid | |||
;; | |||
stop) | |||
/usr/local/bin/mongrel_rails stop -P rails-8001.pid | |||
/usr/local/bin/mongrel_rails stop -P rails-8002.pid | |||
/usr/local/bin/mongrel_rails stop -P rails-8003.pid | |||
;; | |||
*) | |||
cat <<EOF | |||
USAGE: $0 <start|stop|restart> | USAGE: $0 <start|stop|restart> | ||
Mongrel places it's pid files in the RAILS_ROOT directory, which must be | Mongrel places it's pid files in the RAILS_ROOT directory, which must be | ||
writable by the calling user. | writable by the calling user. | ||
EOF | EOF | ||
esac | esac | ||
rcrails | rcrails | ||
#!/usr/local/bin/bash | #!/usr/local/bin/bash | ||
# | # | ||
# This is proxy skript to start-stop mongrel_rails servers | # This is proxy skript to start-stop mongrel_rails servers | ||
# This script can be placed in /etc/init.d or other rc startup directory | # This script can be placed in /etc/init.d or other rc startup directory | ||
# and it will pass its first argument to each rails start script. | # and it will pass its first argument to each rails start script. | ||
conf="/usr/local/etc/mongrel.conf" | conf="/usr/local/etc/mongrel.conf" | ||
if [ -f $conf ] | |||
if [ -f $conf ] | then | ||
then | source $conf | ||
fi | |||
fi | |||
# function to do actual calling | |||
# function to do actual calling | start_stop_rails(){ | ||
start_stop_rails(){ | echo "" | ||
echo "Rails directory: $1" | |||
cd $1 | |||
./script/start_mongrel $2 | |||
} | |||
} | |||
# set CMD to first argument | |||
# set CMD to first argument | CMD=$1 | ||
CMD=$1 | |||
for i in $RAILS_SERVERS | |||
for i in $RAILS_SERVERS | do | ||
do | start_stop_rails $i $CMD | ||
done | |||
done | |||
Redaktsioon: 23. jaanuar 2007, kell 19:28
Apache22 ruby on rails and mongrel
Süsteem toimib nii ,et apache suunab vhostide info mongrel serverile mis siis railsi skripte esilemanab
Installime vajalikud päkitsad
cd /usr/ports/apache22 make install with_proxy_modules=yes
cd /usr/ports/lang/ruby18 make install && make clean
cd /usr/ports/devel/ruby-gems make install && make clean
gem install mongrel gem install rails
Loome vajalikud skriptid
pane rcrails /etc/init.d vms kausta ja start_mongrel iga railsi script kausta. start_mongreli sees määra USER ja GROUP, kellena see server jooksma peaks.
/usr/local/etc/rails.conf või muusse faili (muuda vastavalt rcrails skripti) kirjuta näiteks:
RAILS_SERVERS=" /home/rails/progeadmin/ /home/rails/veebiadmin/ "
start_mongrel
#!/usr/local/bin/bash
USER="root"
GROUP="wheel"
case $1 in
start)
/usr/local/bin/mongrel_rails start -d --user $USER --group $GROUP -p 8001 -a 127.0.0.1 -P rails-8001.pid
/usr/local/bin/mongrel_rails start -d --user $USER --group $GROUP -p 8002 -a 127.0.0.1 -P rails-8002.pid
/usr/local/bin/mongrel_rails start -d --user $USER --group $GROUP -p 8003 -a 127.0.0.1 -P rails-8003.pid
;;
restart)
/usr/local/bin/mongrel_rails restart -P rails-8001.pid
/usr/local/bin/mongrel_rails restart -P rails-8002.pid
/usr/local/bin/mongrel_rails restart -P rails-8003.pid
;;
stop)
/usr/local/bin/mongrel_rails stop -P rails-8001.pid
/usr/local/bin/mongrel_rails stop -P rails-8002.pid
/usr/local/bin/mongrel_rails stop -P rails-8003.pid
;;
*)
cat <<EOF
USAGE: $0 <start|stop|restart>
Mongrel places it's pid files in the RAILS_ROOT directory, which must be
writable by the calling user.
EOF
esac
rcrails
#!/usr/local/bin/bash
#
# This is proxy skript to start-stop mongrel_rails servers
# This script can be placed in /etc/init.d or other rc startup directory
# and it will pass its first argument to each rails start script.
conf="/usr/local/etc/mongrel.conf"
if [ -f $conf ]
then
source $conf
fi
# function to do actual calling
start_stop_rails(){
echo ""
echo "Rails directory: $1"
cd $1
./script/start_mongrel $2
}
# set CMD to first argument
CMD=$1
for i in $RAILS_SERVERS
do
start_stop_rails $i $CMD
done