-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rebuild site on config changes #8
Comments
This is a larger structural change... right now we keep track of the site object and its configuration options are meant to be immutable within one process. |
I guess ideally |
But again, it's still a pretty hefty structural change. Hm. |
Is there some tool somehwere to automate ^C -> restart jekyll when _config.yml changes? This is such a pain to work with, considering so many commercial templates for jekyll use _config.yml for bulk of layout and content. |
Not sure how much it helps but, was facing similar problem. I had all the data in _config.yaml file, moved it to data directory (https://jekyllrb.com/docs/datafiles/), now there was no need for it. |
I've written a daemon with functionality like this before. It watched its own config files, and did sanity checking on the loaded config file before updating its running configuration. If dealing with source and destination changes is too difficult for now, I think a reasonable short term solution would be comparing the keys in the new file and exiting if those values have changed. Or for a very hacky quick fix, exiting if the file changes at all. Continuing to run violates the user's expectations that the changes they made have taken effect. |
I'd also love this, as I also have Jekyll themes that have a lot of config in Surely the process could just restart itself when it detects a change to the config. Would that really need a lot of rearchitecting? |
I agree, it will not be a big effort to implement this way, but it will be a huge help (yes, not the best solution, indeed, but it would be useful if it had a separate option that would be turned off by default, it would be backward compatible too) Anyway, I'm using this script to achieve the same, far from perfect, but it will do what it should. #!/bin/bash
REF_FILE="./.reftime"
ALL_PARAMS=$@
start_process() {
echo -e "\nStarting to serve...\n"
reset_watcher
rm -Rf _site
bundle exec jekyll serve ${ALL_PARAMS} &
PROC_PID=$!
echo -e "\n\n\n"
}
stop_process() {
echo -e "\nStopping to serve...\n"
kill -SIGTERM ${PROC_PID}
wait ${PROC_PID} # Wait for the process to terminate
rm -f "${REF_FILE}"
}
check_watched_file_changed() {
RES="$(find "$1" -newer "${REF_FILE}")"
if [ "${RES}x" == "x" ]; then
return 1
else
return 0
fi
}
reset_watcher() {
touch "${REF_FILE}"
}
handle_file_changes() {
# Space separated list of files to watch
FILES_TO_WATCH=("./_config.yml")
for FILE in "${FILES_TO_WATCH[@]}"; do
if check_watched_file_changed "${FILE}" ; then
echo -e "\nFile $file changed. Restarting to serve...\n"
stop_process
start_process
reset_watcher
break # Break out of the loop after the first file change
fi
done
}
# Main loop
start_process
while true; do
KEY=0
# Check for keyboard input without blocking
read -t 1 -n 1 KEY
case ${KEY} in
s)
stop_process
exit 0
;;
r)
stop_process
start_process
;;
esac
handle_file_changes
sleep 1
done
|
If I run jekyll serve --watch the site does not seem to rebuild when a configuration file (_config.yml) changes.
Ideally --watch could watch config files too.
The text was updated successfully, but these errors were encountered: