[实战AWS EC2]五、基于Ubuntu,Tengine服务器构建Git管理NodeJs,Redis,MongoDB的网站
发布于 10 年前 作者 sogego 5479 次浏览 最后一次编辑是 8 年前

**技术交流加入QQ群:261654896 **

实战AWS EC2文章目录http://cnodejs.org/topic/5295e58aa6957a0809b0fe43

**安装配置supervisor==============把log文件全部放在/mnt目录下========= **

**1.安装 sudo apt-get install supervisor **

**2. cd /etc/supervisor/conf.d/ 目录下 **

3. 编辑配置文件

//[program:启动程序名称]

//需要执行的命令,来启动redis

//supervisor启动的时候是否随着同时启动

//当程序跑出exit的时候,这个program会自动重启

//程序重启时候停留在runing状态的秒数

==================================

**vi redis_super.conf 文件 并添加下面redis对应的5行,在supervisor配置启动redis的conf(如果使用supervisor就设置redis为前台运行:daemonize no 否则就设置为后台运行:daemonize yes) **

[program:redis]

command = redis-server /etc/redis.conf

autostart=true

autorestart=true

startsecs=3

stdout_logfile=/mnt/redis.log

===============如果tengine(nginx)还没有安装,点击这里===================

**vi nginx_super.conf 文件 并添加下面nginx对应的5行,在supervisor配置启动nginx的conf,如果使用(supervisor 要在/usr/local/nginx/conf/nginx.conf中头一行添加 daemon off;) **

[program:nginx]

command = /usr/local/nginx/sbin/nginx

autostart=true

autorestart=true

startsecs=3

==================================
vi mongodb_super.conf 文件 并添加下面mongodb对应的5行,在supervisor配置启动mongodb的conf,没有fork命令。

[program:mongodb]

command = /data/mongodb/bin/mongod --dbpath=/data/dbs/mongodb --logpath=/mnt/mongodb.log --auth --port=27017

autostart=true

autorestart=true

startsecs=3

==================================
vi phoneqq.com_super.conf 文件 并添加下面phoneqq.com对应的5行,在supervisor配置启动phoneqq.com的conf

[program:phoneqq.com]

command = node /data/www/phoneqq.com/app.js

autostart=true

autorestart=true

startsecs=3

stdout_logfile=/mnt/phoneqq.com.log

==================================
vi sogego.com_super.conf 文件 并添加下面sogego.com对应的5行,在supervisor配置启动sogego.com的conf

[program:sogego.com]

command = node /data/www/sogego.com/app.js

autostart=true

autorestart=true

startsecs=3

stdout_logfile=/mnt/sogego.com.log

**4. 修改:vi /etc/redis.conf 文件 **

修改 daemonize no

**5. 修改:vi /usr/local/nginx/conf/nginx.conf 文件 **

顶上一行加上,记得nginx配置每行用;号结束啊:daemon off;

**6. 以下为supervisor使用方法 **

supervisord //启动supervisor

supervisorctl //打开命令行

[root@vm14211 ~]# supervisorctl

mongodb RUNNING pid 779, uptime 0:01:19 nginx RUNNING pid 783, uptime 0:01:19 redis RUNNING pid 782, uptime 0:01:19 sogego.com RUNNING pid 784, uptime 0:01:19

ctl中: help //查看命令

ctl中: status //查看状态

回到顶部