Skip to content

Commit

Permalink
增加选项:指定配置文件路径
Browse files Browse the repository at this point in the history
  • Loading branch information
phith0n committed Aug 20, 2015
1 parent 001373c commit cd14eaa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ http://stackoverflow.com/questions/21242107/pip-install-pil-dont-install-into-vi

- 启动Mongodb、Redis、Minos

nohup ./main.py --host=waf.science --port=8765 --url=http://waf.science &
nohup ./main.py --host=waf.science --port=8765 --url=http://waf.science --config=./config.yaml &

\- \-host=domain 你的域名,如waf.science,默认为localhost
\- \-port=port 你的端口,默认为8765
\- \-url=url 显示在前端的域名*,默认为“http://” + host + “:” + port
\- \-host=domain 你的域名,如waf.science,默认为localhost
\- \-port=port 你的端口,默认为8765
\- \-url=url 显示在前端的域名*,默认为“http://” + host + “:” + port
\- \-config=config 配置文件所在路径,默认为当前目录下的config.yaml,正常情况下无需修改

\* 这里说明一下。Minos需要监听本地一个端口,默认为8765,则用户可以通过localhost:8765访问。但实际生产环境中,Minos一般搭建在内网,并通过nginx等服务器转发至外网,其URL可能是http://waf.science 。那么,url实际上是显示在前端HTML HEAD <base>中的地址,而host与port才是实际上Minos监听的地址。
如果你不用nginx做转发,想直接搭建Minos在外网服务器,那么只需./main.py --port=80 --url=http://yourdomain.com 即可。
Expand Down
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/usr/bin/python
import tornado.ioloop
import tornado.web, tornado.options
import motor, sys, os, yaml
import motor
import sys
import os
import yaml
from concurrent import futures
import controller.base

tornado.options.define("port", default=8765, help="Run server on a specific port", type=int)
tornado.options.define("host", default="localhost", help="Run server on a specific host")
tornado.options.define("url", default=None, help="Url to show in HTML")
tornado.options.define("config", default="./config.yaml", help="config file's full path")
tornado.options.parse_command_line()

if not tornado.options.options.url:
Expand All @@ -17,7 +21,7 @@
"base_url": tornado.options.options.url,
"template_path": "templates",
"cookie_secret": "s3cr3tk3y",
"config_filename": "config.yaml",
"config_filename": tornado.options.options.config,
"compress_response": True,
"default_handler_class": controller.base.NotFoundHandler,
"xsrf_cookies": True,
Expand Down

0 comments on commit cd14eaa

Please sign in to comment.