2012-11-06 17 views

回答

0

我有一個小小的shell腳本來創建我的配置文件。

create_upstart() { 
    project=$1 
    file=$2 
    conf="/etc/init/${project}_${file}.conf" 

    cat > $conf << EOF 
    #!upstart 

    description "Node Process - $1" 
    author  "Geert Pasteels" 

    respawn 

    start on (local-filesystems and net-device-up IFACE=eth0) 
    stop on shutdown 

    script 
    export NODE_ENV="production" 
    export PORT="3001" 
    exec /usr/bin/node /var/www/$project/current/$file.js >> /var/www/$project/shared/logs/$file 2>&1 
    end script 
EOF 

    echo $conf 

    # Restart upstart script 
    stop ${project}_${file} 
    start ${project}_${file} 
    echo Restarted ${project}_${file} 
} 

create_upstart "$1" "$2" 

我把這個和TJ's deploy結合使用。所以在我的post部署掛鉤我做startup app file.

+0

謝謝。我在我的服務器上使用nvm。我該如何運行nodejs?我應該爲nodejs創建一個特定的用戶 – Erik

相關問題