- 浏览: 119428 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
sitoto:
git revert 和reset的区别这里讲一下git re ...
git的revert和reset和 git push -
sitoto:
If x is your column or vector:s ...
string.strip--去除字符串空格 -
xueluowuhen_1:
正好用到了 谢谢!
ruby的数据类型转换-字符串转整型 -
ChuanSu:
jkjjlkjkljkljlkjlkj
关于建站 -
ChuanSu:
[/main void {zhedoushi shenm yi ...
关于建站
先前的开发的Ruby on Rails网站使用的服务程序是Mongrel + Nginx, 现在用了Rails 3, 发现Mongrel对它有兼容问题, 所以要换一个。 虽然现在Phusion Passenger大行其道, 但使用前要重新编译Nginx。 为了避免重新安装nginx,我找到mongrel的替代品Unicorn。 没想到unicorn的设置非常方便。 我记录在这里供大家参考:
安装unicorn:
sudo gem install unicorn
创建网站配置文件(myproject是项目名称):
sudo mkdir /etc/unicorn
cd /etc/unicorn/
sudo nano /etc/unicorn/myproject.conf
内容如下:
RAILS_ROOT=/www/myproject
RAILS_ENV=production
在网站里再创建一个unicorn配置文件
nano /www/myproject/config/unicorn.rb
内容如下:
# Minimal sample configuration file for Unicorn (not Rack) when used
# with daemonization (unicorn -D) started in your working directory.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
# See also http://unicorn.bogomips.org/examples/unicorn.conf.rb for
# a more verbose configuration using more features.
app_path = "/www/myproject"
listen 8080 # by default Unicorn listens on port 8080
worker_processes 2 # this should be >= nr_cpus
pid "#{app_path}/tmp/pids/unicorn.pid"
stderr_path "#{app_path}/log/unicorn.log"
stdout_path "#{app_path}/log/unicorn.log"
设置unicorn启动脚本:
sudo nano /etc/init.d/unicorn_init
脚本内容:
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
## RAILS_ENV=production
## RAILS_ROOT=/var/apps/www/my_app/current
#
# This configures a unicorn master for your app at /var/apps/www/my_app/current running in
# production mode. It will read config/unicorn.rb for further set up.
#
# You should ensure different ports or sockets are set in each config/unicorn.rb if
# you are running more than one master concurrently.
#
# If you call this script without any config parameters, it will attempt to run the
# init command for all your unicorn configurations listed in /etc/unicorn/*.conf
#
# /etc/init.d/unicorn start # starts all unicorns
#
# If you specify a particular config, it will only operate on that one
#
# /etc/init.d/unicorn start /etc/unicorn/my_app.conf
set -e
sig () {
test -s "$PID" && kill -$1 `cat "$PID"`
}
oldsig () {
test -s "$OLD_PID" && kill -$1 `cat "$OLD_PID"`
}
cmd () {
case $1 in
start)
sig 0 && echo >&2 "Already running" && exit 0
echo "Starting"
$CMD
;;
stop)
sig QUIT && echo "Stopping" && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && echo "Forcing a stop" && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig USR2 && sleep 5 && oldsig QUIT && echo "Killing old master" `cat $OLD_PID` && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
$CMD
;;
upgrade)
sig USR2 && echo Upgraded && exit 0
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
$CMD
;;
rotate)
sig USR1 && echo rotated logs OK && exit 0
echo >&2 "Couldn't rotate logs" && exit 1
;;
*)
echo >&2 "Usage: $0 "
exit 1
;;
esac
}
setup () {
echo -n "$RAILS_ROOT: "
cd $RAILS_ROOT || exit 1
export PID=$RAILS_ROOT/tmp/pids/unicorn.pid
export OLD_PID="$PID.oldbin"
CMD="/usr/bin/unicorn_rails -c config/unicorn.rb -E $RAILS_ENV -D"
}
start_stop () {
# either run the start/stop/reload/etc command for every config under /etc/unicorn
# or just do it for a specific one
# $1 contains the start/stop/etc command
# $2 if it exists, should be the specific config we want to act on
if [ $2 ]; then
. $2
setup
cmd $1
else
for CONFIG in /etc/unicorn/*.conf; do
# import the variables
. $CONFIG
setup
# run the start/stop/etc command
cmd $1
done
fi
}
ARGS="$1 $2"
start_stop $ARGS
注意将里面的/usr/bin/unicorn_rails 换成你系统中unicorn_rails程序的实际路径。
设置unicorn_init文件属性:
sudo chmod 755 /etc/init.d/unicorn_init
启动unicorn:
/etc/init.d/unicorn_init
修改nginx的配置文件,加入unicorn的代理设置:
upstream myproject_mongrel {
server 127.0.0.1:8080 fail_timeout=0;
}
这部分跟使用mongrel的类似的。
这样unicorn的设置就完成了。 刚设置好,感觉unicorn跟mongrel一样, 都是比较吃内存的, 一启动就占了50M. 不知道会不会也像mongrel一样把内存吃爆, 会得话得设置监控软件(如god)看住它。
http://www.cslog.cn/Content/unicorn-for-ruby-on-rails/
安装unicorn:
sudo gem install unicorn
创建网站配置文件(myproject是项目名称):
sudo mkdir /etc/unicorn
cd /etc/unicorn/
sudo nano /etc/unicorn/myproject.conf
内容如下:
RAILS_ROOT=/www/myproject
RAILS_ENV=production
在网站里再创建一个unicorn配置文件
nano /www/myproject/config/unicorn.rb
内容如下:
# Minimal sample configuration file for Unicorn (not Rack) when used
# with daemonization (unicorn -D) started in your working directory.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
# See also http://unicorn.bogomips.org/examples/unicorn.conf.rb for
# a more verbose configuration using more features.
app_path = "/www/myproject"
listen 8080 # by default Unicorn listens on port 8080
worker_processes 2 # this should be >= nr_cpus
pid "#{app_path}/tmp/pids/unicorn.pid"
stderr_path "#{app_path}/log/unicorn.log"
stdout_path "#{app_path}/log/unicorn.log"
设置unicorn启动脚本:
sudo nano /etc/init.d/unicorn_init
脚本内容:
#!/bin/sh
#
# init.d script for single or multiple unicorn installations. Expects at least one .conf
# file in /etc/unicorn
#
# Modified by jay@gooby.org http://github.com/jaygooby
# based on http://gist.github.com/308216 by http://github.com/mguterl
#
## A sample /etc/unicorn/my_app.conf
##
## RAILS_ENV=production
## RAILS_ROOT=/var/apps/www/my_app/current
#
# This configures a unicorn master for your app at /var/apps/www/my_app/current running in
# production mode. It will read config/unicorn.rb for further set up.
#
# You should ensure different ports or sockets are set in each config/unicorn.rb if
# you are running more than one master concurrently.
#
# If you call this script without any config parameters, it will attempt to run the
# init command for all your unicorn configurations listed in /etc/unicorn/*.conf
#
# /etc/init.d/unicorn start # starts all unicorns
#
# If you specify a particular config, it will only operate on that one
#
# /etc/init.d/unicorn start /etc/unicorn/my_app.conf
set -e
sig () {
test -s "$PID" && kill -$1 `cat "$PID"`
}
oldsig () {
test -s "$OLD_PID" && kill -$1 `cat "$OLD_PID"`
}
cmd () {
case $1 in
start)
sig 0 && echo >&2 "Already running" && exit 0
echo "Starting"
$CMD
;;
stop)
sig QUIT && echo "Stopping" && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && echo "Forcing a stop" && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig USR2 && sleep 5 && oldsig QUIT && echo "Killing old master" `cat $OLD_PID` && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
$CMD
;;
upgrade)
sig USR2 && echo Upgraded && exit 0
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
$CMD
;;
rotate)
sig USR1 && echo rotated logs OK && exit 0
echo >&2 "Couldn't rotate logs" && exit 1
;;
*)
echo >&2 "Usage: $0 "
exit 1
;;
esac
}
setup () {
echo -n "$RAILS_ROOT: "
cd $RAILS_ROOT || exit 1
export PID=$RAILS_ROOT/tmp/pids/unicorn.pid
export OLD_PID="$PID.oldbin"
CMD="/usr/bin/unicorn_rails -c config/unicorn.rb -E $RAILS_ENV -D"
}
start_stop () {
# either run the start/stop/reload/etc command for every config under /etc/unicorn
# or just do it for a specific one
# $1 contains the start/stop/etc command
# $2 if it exists, should be the specific config we want to act on
if [ $2 ]; then
. $2
setup
cmd $1
else
for CONFIG in /etc/unicorn/*.conf; do
# import the variables
. $CONFIG
setup
# run the start/stop/etc command
cmd $1
done
fi
}
ARGS="$1 $2"
start_stop $ARGS
注意将里面的/usr/bin/unicorn_rails 换成你系统中unicorn_rails程序的实际路径。
设置unicorn_init文件属性:
sudo chmod 755 /etc/init.d/unicorn_init
启动unicorn:
/etc/init.d/unicorn_init
修改nginx的配置文件,加入unicorn的代理设置:
upstream myproject_mongrel {
server 127.0.0.1:8080 fail_timeout=0;
}
这部分跟使用mongrel的类似的。
这样unicorn的设置就完成了。 刚设置好,感觉unicorn跟mongrel一样, 都是比较吃内存的, 一启动就占了50M. 不知道会不会也像mongrel一样把内存吃爆, 会得话得设置监控软件(如god)看住它。
http://www.cslog.cn/Content/unicorn-for-ruby-on-rails/
发表评论
-
mysql2安装错误
2013-08-08 13:22 634administrator@ubuntu:~/store$ g ... -
Capistrano deploy ** Host key verification failed
2012-07-13 20:44 1013Known Hosts bug If you are not ... -
nginx deploy.rb
2012-06-12 11:46 0http://library.linode.com/web-s ... -
cap deploy
2012-06-12 11:18 0问题描述:cap deploy 部署最后提示错误: s ... -
Ubuntu上Mysql数据库文件备份问题
2012-06-03 13:41 0数据库文件默认放在:/var/lib/mysql 这个路径可以 ... -
ubuntu安装nokogiri错误
2012-05-30 19:34 773gem install nokogiri 提示错误,冒失一些 ... -
ubuntu安装mongodb
2012-05-29 19:14 0sudo apt-get install mongodb 配 ... -
Adding users to sudoers through shell script
2012-05-27 15:24 653You could simply echo (with ele ... -
mysql2安装失败in ubuntu
2012-05-27 16:39 775> gem install mysql2 Buildi ... -
ubuntu安装mysql-server
2012-05-26 15:46 745一。mysql安装 >sudo apt-get ins ... -
Ubuntu putty 的复制与粘贴
2012-05-26 12:48 1079在Ubuntu下经常用putty,老是为这个复制粘贴的事情 ... -
phusion passenger standalone
2012-05-26 13:04 853为了测试这个 passenger 先 放个项目 上去。 ... -
ubuntu下普通用户app 下的rvm安装
2012-05-26 11:01 839准备: 安装 curl :sudo apt-get in ... -
ubuntu下root用户下的rvm安装
2012-05-26 10:49 1729声明:我是使用root 帐户安装的。。安装的是 多用户,所以直 ... -
ubuntu 配置详解
2012-05-26 09:28 0ubuntu新建帐户 :并加入到 sudoers里面。 su ... -
sqlite3-ruby gem can't find sqlite3.h on ubuntu
2012-05-25 18:34 768sqlite3-ruby gem can't find sql ... -
ImageMagick in ubuntu
2012-05-23 15:04 710ImageMagick is a powerful suite ... -
【Vim编程】如何去掉 修改文件后系统会自动生成的一个带~的备份文件
2012-05-20 16:20 938怎么让Vim不自动生成这些备份文件呢? 1. 找到你的Vi ... -
Rails server Error:Address already in use
2012-05-17 19:21 1584Hi, For some reason ... -
Redis配置和启动【转】
2012-05-17 17:17 757启动redis时候提示: ARE YOU SU ...
相关推荐
Windows7_Cygwin_Git_RVM_Ruby1.9.3_Rails3_MongoD B_Nginx_Unicorn_Rspec_Guard_Spork(2-Ruby on Rails3 安装配置
在 Heroku 上使用 Puma Web 服务器的 Ruby on Rails 使用部署在Puma Web 服务器的示例 Ruby on Rails 应用程序。 2015 年 1 月 23 日,Heroku 宣布 Puma 为推荐的 Ruby Web 服务器。 来自: Heroku 现在推荐使用 ...
安装Brimir是一个相当简单的Ruby on Rails应用程序。 进行设置的唯一困难是如何使收到的电子邮件正常工作。 有关详细信息,请参见下一部分。 任何Rails应用程序都首先需要具有Ruby支持的Web服务器。 我们自己使用...
使用Shell脚本通过git更新远程服务器上的rails应用,并执行bundle install、rake db:migration、asset precompile和重启unicorn... 尝试使用Capistrano进行部署,但是遇到了很多问题,比如配置错误、ruby版本不匹配...
您可以注册最方便的日期顶部屏幕新注册画面个人资料图片预览实现登入画面讲师列表画面讲师注册画面讲师信息详细画面我的页面网站网址http://13.112.152.26/ 基本认证用户名admin密码0322版本信息Ruby 2.5.1版Ruby on...
利用Ruby 2.6.3 API的完整实现,该实现使用mruby C, 和的混合体。 利用为mruby定制的Ruby标准库程序包的实现,包括delegate ,可forwardable , json , monitor , ostruct , set , strscan和uri 。 利用。愚人...
rails 应用程序使用bundle exec unicorn运行 #快速设置 将unicorn文件复制到/usr/local/etc/rc.d并使用chmod a+x unicorn将其标记为可执行文件。 编辑你的rc.conf 。 在这个例子中,我们将添加一个 Redmine 和一个...
首先需要你熟悉Ruby on Rails开发,其中deploy文件有些地方是需要换成自己的配置: set :repo_url, '这里换成自己的git服务器地址' 我是使用的Thin服务器作为部署服务器,如果只想在development模式下运行请忽略下面...
capistrano-3-rails-template, 使用 Capistrano 3部署 Rails 应用程序的模板 Capistrano 3 Rails 配置概述这是部署带有的Ruby on Rails 应用程序的示例配置,包括使用Unicorn和Sidekiq后台员工部署的零停机。...
Windows7+Cygwin+Git+RVM+Ruby1.9.3+Rails3+MongoDB+N ginx+Unicorn+Rspec+Guard+Spork(1-Cygwin 安装配置)
Docker Rails + Nginx + Unicorn(来自Ubuntu 16.04和Ruby 2.4.0) 易于使用的docker导轨。 较少的配置,负担得起的生产。 包括什么 独角兽,nginx,领班 mysql,PostgreSQL库 用法 在您的项目中创建Dockerfile并...
Unicorn CNB为在Unicorn服务器上运行的给定的ruby应用程序设置启动命令。 一体化 该CNB编写了一个start命令,因此目前还没有可以想象的情况,您需要将其作为依赖项。 如果用户喜欢包含其他功能,则可以独立于...
Unicorn
TheRails部署......Applications > Ruby on Rails on Ubuntu 14.04 (Nginx + Unicorn)查看你的邮件 Your new droplet has been created!You can access it using the following credentials:IP Addres
WebFaction 私有应用程序栈shell 脚本webfaction.sh将自动构建和配置您自己的私有Ruby on Rails堆栈。 它是为用户编写的,但相当通用。 假定目录$HOME/logs/user和$HOME/webapps/$APP_NAME存在。提供什么混帐sqlite ...
Ruby / Ruby on Rails / MySQL / HTMLCSSJavaScript / GitHub / AWS(EC2,Route53) 開発環境 エディタ:Visual Studio Code 管理ツール:GitHub,trello 言語・フレームワーク:Ruby・HTMLCSSJavaScript・...
基本介绍 rails4快速开发产品原型的基础代码,结构清晰,注释详细,遵守rails约定规范,包含一些基本的功能。可以查看完整版。 方案 Ruby管理:rbenv Ruby: Ruby 2.1.2 后端框架:Rails 4.2.0 ...搜索系统,使用更强大
rails_stack 食谱 TODO:在此处输入食谱说明。 例如,这本食谱使您最喜欢的早餐三明治。 要求 TODO:列出您的食谱要求。 确保包含本说明书对平台、库、其他说明书、软件包、操作系统等的任何要求。 例如 包裹 ...
Based on Matthew Graeber's powershell attacks and the powershell bypass technique presented by David Kennedy (TrustedSec) and Josh Kelly at Defcon 18.Usage is simple just run Magic Unicorn (ensure ...
独角兽Unicorn是基本的配置服务器,使您能够将应用程序进程订阅到一个或多个配置文件的确切部分,并在更改配置时读取事件。用法独角兽应用程序由一名根主管和许多工作人员组成。 当您加载配置文件时,另一个工作程序...