久久精品精选,精品九九视频,www久久只有这里有精品,亚洲熟女乱色综合一区
    分享

    Linux下Unicorn服務器配置

     株野 2017-04-10

    Unicorn 是什么?
    1. 為 Rack 應用程序設計的 HTTP server
    2. 是一個利用Unix的高級特性開發的
    3. 為具備低延遲,高帶寬的連接的客戶服務

    特性:
    1. 為 Rack, Unix, 快速的客戶端和易調試而設計。
    2. 完全兼容 Ruby 1.8 和 1.9。
    3. 進程管理:Unicorn 會獲取和重啟因應用程序出錯導致死亡的任務,不需要自己管理多個進程和端口。Unicorn 可以產生和管理任何數量的任務進程。
    4. 負載均衡完全由操作系統(Unix)核心完成。在繁忙的任務進程時,請求也不會堆積。
    5. 不需要關心應用程序是否是線程安全的,workers 運行在特們自己獨立的地址空間,且一次只為一個客戶端服務。
    6. 支持所有的 Rack 應用程序。
    7. 使用 USR1 信號來固定重復打開應用程序的所有日志文件。Unicorn 也可以逐步的確定一個請求的多行日志放在同一個文件中。
    8. nginx 式的二進制升級,不丟失連接。你可以升級 Unicorn、你的整個應用程序、庫、甚至 Ruby 編輯器而不丟失客戶端連接。
    9. 在 fork 進程時如果由特殊需求可以使用 before_fork 和 after_fork 。如果“preload_app“ 為 false 時,則不能使用。
    10. 可以使用 copy-on-wirte-friendly 內存管理來節約內容(通過設置 “preload_app" 為 true )。
    11. 可以監聽多接口,包括:UNIX sockets,每個 worker process 也可以在簡單調試時通過 after_fork 鉤子綁定到私有的端口。
    12. 配置使用簡單易用的 Ruby DSL。

     

    Linux下Unicorn服務器安裝配置:

    gem install unicorn


    給工程創建一個unicorn配置文件

    new_sxcoalts2.0/config/unicorn.rb
    內容如下:
    app_path = "/work/new_sxcoalts2.0" #程序路徑
    listen 3000 # 端口號
    worker_processes 2 # cpu核數
    pid "#{app_path}/tmp/pids/unicorn.pid"
    stderr_path "#{app_path}/log/unicorn.log"
    stdout_path "#{app_path}/log/unicorn.log"
    rails_env = 'production'


    啟動:
    進入到工程根目錄 cd /work/new_sxcoalts2.0/
    unicorn_rails -c /work/new_sxcoalts2.0/config/unicorn.rb
    參數-c 意思為執行后面配置文件里的內容

    停止服務:
    后臺服務:  Kill 進程
    命令行服務:  ctrl + c


    建立啟動,關閉服務:
    創建工程配置文件夾:
    /etc/unicorn
    在此目錄下添加所有需要的工程配置(可放置多個)
    例如:project1.conf
    內容為
    RAILS_ROOT=/work/project1
    RAILS_ENV=production

    編寫unicorn 啟動腳本
    在/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/new_sxcoalts_2.0.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/new_sxcoalts_2.0.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="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

    執行命令:
    /etc/init.d/unicorn_init start/stop/restart

    Unicorn 的詳細介紹請點這里
    Unicorn 的下載地址請點這里

    linux

      本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發現有害或侵權內容,請點擊一鍵舉報。
      轉藏 分享 獻花(0

      0條評論

      發表

      請遵守用戶 評論公約

      類似文章 更多

      主站蜘蛛池模板: 高清一卡二卡三卡四免费| 久久久这里只有精品10| 亚洲日韩国产精品第一页一区| 播放灌醉水嫩大学生国内精品 | 国产99在线 | 免费| 国产日产欧产精品精品软件| 92精品国产自产在线观看481页| 97精品伊人久久大香线蕉APP| 中文字幕日韩有码一区| 国产高跟黑色丝袜在线 | 午夜无码大尺度福利视频| 亚洲一区中文字幕人妻| 伊人狠狠色丁香婷婷综合| 伊人久久综合无码成人网| 国内精品视频一区二区三区八戒| 欧美黑人又粗又大高潮喷水| 国产成人综合95精品视频| 欧美亚洲一区二区三区| 蜜桃视频一区二区在线观看| 亚洲一区二区三区在线观看精品中文| 18级成人毛片免费观看| 精品九九人人做人人爱| 久久国产福利播放| 欧美高清狂热视频60一70| 波多野结衣AV一区二区全免费观看| 国产欧美成人XXX视频| 亚洲AV综合色区在线观看| 亚洲色成人网站WWW永久| 国产免费一区二区不卡| 久久久久无码精品国产| 强奷漂亮少妇高潮麻豆| 国产精品久久中文字幕| 51国偷自产一区二区三区| 毛片大全真人在线| 日韩有码中文字幕国产| 久久狠狠高潮亚洲精品| 午夜大片爽爽爽免费影院| 国产精品自在线拍国产手机版| 国内丰满熟女出轨VIDEOS| 成人免费AA片在线观看| 福利在线视频一区二区|