本文整理汇总了Python中aspen.website.Website.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python Website.shutdown方法的具体用法?Python Website.shutdown怎么用?Python Website.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aspen.website.Website
的用法示例。
在下文中一共展示了Website.shutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import shutdown [as 别名]
def main(argv=None):
"""http://aspen.io/cli/
"""
try:
# Do imports.
# ===========
# These are in here so that if you Ctrl-C during an import, the
# Keyboard Interupt is caught and ignored. Yes, that's how much I care.
# No, I don't care enough to put aspen/__init__.py in here too.
import os
import logging
import socket
import sys
import time
from os.path import exists, join
from aspen.server import restarter
from aspen.website import Website
log = logging.getLogger('aspen.cli')
# Actual stuff.
# =============
if argv is None:
argv = sys.argv[1:]
website = Website(argv)
try:
if hasattr(socket, 'AF_UNIX'):
if website.sockfam == socket.AF_UNIX:
if exists(website.address):
log.info("Removing stale socket.")
os.remove(website.address)
if website.port is not None:
welcome = "port %d" % website.port
else:
welcome = website.address
log.info("Starting %s engine." % website.engine.name)
log.warn("Greetings, program! Welcome to %s." % welcome)
website.engine.init(website)
if website.changes_kill:
restarter.install(website)
website.engine.start(website)
finally:
if hasattr(socket, 'AF_UNIX'):
if website.sockfam == socket.AF_UNIX:
if exists(website.address):
os.remove(website.address)
website.shutdown()
website.engine.stop()
except KeyboardInterrupt, SystemExit:
pass