mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #1200 from tomtung/patch-1
`ctrl+c` correctly terminates&reenables `fab serve`
This commit is contained in:
commit
89de903925
1 changed files with 13 additions and 1 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
from fabric.api import *
|
from fabric.api import *
|
||||||
import fabric.contrib.project as project
|
import fabric.contrib.project as project
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
import SimpleHTTPServer
|
||||||
|
import SocketServer
|
||||||
|
|
||||||
# Local path configuration (can be absolute or relative to fabfile)
|
# Local path configuration (can be absolute or relative to fabfile)
|
||||||
env.deploy_path = 'output'
|
env.deploy_path = 'output'
|
||||||
|
|
@ -32,7 +35,16 @@ def regenerate():
|
||||||
local('pelican -r -s pelicanconf.py')
|
local('pelican -r -s pelicanconf.py')
|
||||||
|
|
||||||
def serve():
|
def serve():
|
||||||
local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
|
os.chdir(env.deploy_path)
|
||||||
|
|
||||||
|
PORT = 8000
|
||||||
|
class AddressReuseTCPServer(SocketServer.TCPServer):
|
||||||
|
allow_reuse_address = True
|
||||||
|
|
||||||
|
server = AddressReuseTCPServer(('', PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
|
||||||
|
|
||||||
|
sys.stderr.write('Serving on port {0} ...\n'.format(PORT))
|
||||||
|
server.serve_forever()
|
||||||
|
|
||||||
def reserve():
|
def reserve():
|
||||||
build()
|
build()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue