mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
quickstart Makefile: use the pelican -S/--serve option for the devserver.
No more acrobatics with PIDs, no background process, no need to stopserver.
This commit is contained in:
parent
a926acf8f3
commit
8e09bc778c
2 changed files with 3 additions and 112 deletions
|
|
@ -46,8 +46,7 @@ help:
|
|||
@echo ' make publish generate using production settings '
|
||||
@echo ' make serve [PORT=8000] serve site at http://localhost:8000'
|
||||
@echo ' make serve-global [SERVER=0.0.0.0] serve (as root) to $(SERVER):80 '
|
||||
@echo ' make devserver [PORT=8000] start/restart develop_server.sh '
|
||||
@echo ' make stopserver stop local server '
|
||||
@echo ' make devserver [PORT=8000] start serve with regenerate '
|
||||
@echo ' make ssh_upload upload the web site via SSH '
|
||||
@echo ' make rsync_upload upload the web site via rsync+ssh '
|
||||
@echo ' make dropbox_upload upload the web site via Dropbox '
|
||||
|
|
@ -86,17 +85,11 @@ endif
|
|||
|
||||
devserver:
|
||||
ifdef PORT
|
||||
$$(BASEDIR)/develop_server.sh restart $$(PORT)
|
||||
$$(PELICAN) -S -o $$(OUTPUTDIR) -s $$(PUBLISHCONF) $$(PELICANOPTS) -p $$(PORT) $$(INPUTDIR)
|
||||
else
|
||||
$$(BASEDIR)/develop_server.sh restart
|
||||
$$(PELICAN) -S -o $$(OUTPUTDIR) -s $$(PUBLISHCONF) $$(PELICANOPTS) $$(INPUTDIR)
|
||||
endif
|
||||
|
||||
stopserver:
|
||||
$(BASEDIR)/develop_server.sh stop
|
||||
@echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
|
||||
|
||||
publish:
|
||||
$$(PELICAN) $$(INPUTDIR) -o $$(OUTPUTDIR) -s $$(PUBLISHCONF) $$(PELICANOPTS)
|
||||
|
||||
ssh_upload: publish
|
||||
scp -P $$(SSH_PORT) -r $$(OUTPUTDIR)/* $$(SSH_USER)@$$(SSH_HOST):$$(SSH_TARGET_DIR)
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
##
|
||||
# This section should match your Makefile
|
||||
##
|
||||
PELICAN=$${PELICAN:-$pelican}
|
||||
PELICANOPTS=$pelicanopts
|
||||
|
||||
BASEDIR=$$(pwd)
|
||||
INPUTDIR=$$BASEDIR/content
|
||||
OUTPUTDIR=$$BASEDIR/output
|
||||
CONFFILE=$$BASEDIR/pelicanconf.py
|
||||
|
||||
###
|
||||
# Don't change stuff below here unless you are sure
|
||||
###
|
||||
|
||||
SRV_PID=$$BASEDIR/srv.pid
|
||||
PELICAN_PID=$$BASEDIR/pelican.pid
|
||||
|
||||
function usage(){
|
||||
echo "usage: $$0 (stop) (start) (restart) [port]"
|
||||
echo "This starts Pelican in debug and reload mode and then launches"
|
||||
echo "an HTTP server to help site development. It doesn't read"
|
||||
echo "your Pelican settings, so if you edit any paths in your Makefile"
|
||||
echo "you will need to edit your settings as well."
|
||||
exit 3
|
||||
}
|
||||
|
||||
function alive() {
|
||||
kill -0 $$1 >/dev/null 2>&1
|
||||
}
|
||||
|
||||
function shut_down(){
|
||||
PID=$$(cat $$SRV_PID)
|
||||
if [[ $$? -eq 0 ]]; then
|
||||
if alive $PID; then
|
||||
echo "Stopping HTTP server"
|
||||
kill $$PID
|
||||
else
|
||||
echo "Stale PID, deleting"
|
||||
fi
|
||||
rm $$SRV_PID
|
||||
else
|
||||
echo "HTTP server PIDFile not found"
|
||||
fi
|
||||
|
||||
PID=$$(cat $$PELICAN_PID)
|
||||
if [[ $$? -eq 0 ]]; then
|
||||
if alive $$PID; then
|
||||
echo "Killing Pelican"
|
||||
kill $$PID
|
||||
else
|
||||
echo "Stale PID, deleting"
|
||||
fi
|
||||
rm $$PELICAN_PID
|
||||
else
|
||||
echo "Pelican PIDFile not found"
|
||||
fi
|
||||
}
|
||||
|
||||
function start_up(){
|
||||
local port=$$1
|
||||
echo "Starting up Pelican and HTTP server"
|
||||
shift
|
||||
$$PELICAN --debug --autoreload -r $$INPUTDIR -o $$OUTPUTDIR -s $$CONFFILE $$PELICANOPTS &
|
||||
pelican_pid=$$!
|
||||
echo $$pelican_pid > $$PELICAN_PID
|
||||
cd $$OUTPUTDIR
|
||||
$PY -m pelican.server $$port &
|
||||
srv_pid=$$!
|
||||
echo $$srv_pid > $$SRV_PID
|
||||
cd $$BASEDIR
|
||||
sleep 1
|
||||
if ! alive $$pelican_pid ; then
|
||||
echo "Pelican didn't start. Is the Pelican package installed?"
|
||||
return 1
|
||||
elif ! alive $$srv_pid ; then
|
||||
echo "The HTTP server didn't start. Is there another service using port" $$port "?"
|
||||
return 1
|
||||
fi
|
||||
echo 'Pelican and HTTP server processes now running in background.'
|
||||
}
|
||||
|
||||
###
|
||||
# MAIN
|
||||
###
|
||||
[[ ($$# -eq 0) || ($$# -gt 2) ]] && usage
|
||||
port=''
|
||||
[[ $$# -eq 2 ]] && port=$$2
|
||||
|
||||
if [[ $$1 == "stop" ]]; then
|
||||
shut_down
|
||||
elif [[ $$1 == "restart" ]]; then
|
||||
shut_down
|
||||
start_up $$port
|
||||
elif [[ $$1 == "start" ]]; then
|
||||
if ! start_up $$port; then
|
||||
shut_down
|
||||
fi
|
||||
else
|
||||
usage
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue