Skip to content

serve does not work with watch #243

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

Open
tedwardd opened this issue Mar 28, 2025 · 3 comments
Open

serve does not work with watch #243

tedwardd opened this issue Mar 28, 2025 · 3 comments

Comments

@tedwardd
Copy link

tedwardd commented Mar 28, 2025

Expected: marmite --serve --watch <input> <output> should auto-build on file changes and serve those new files

Actual: The default "No Content Found" page is served

When combining --watch and --serve in the same command, the generated site files do not serve properly. I am unable to determine from the debug output why this might be but I've outlined some tests below that seem to indicate that this feature is not working as intended:

  • Run marmite --serve <input> -- works as expected
  • Run marmite <input> <input>/site followed by marmite --serve <input> -- No content found
  • Run marmite --watch <input> <output> --serve <input> -- unexpected argument for the second <input>
  • Run marmite --watch <input> --serve <output> -- No content found
  • Run marmite --watch <input> --serve <input> -- infinite regeneration loop

Please let me know if I can provide any further detail or clarification. I am, admitedly, new to the project so I readily admit I may be using this incorrectly but the use case as described in #34 seems to indicate this is a bug.

@rochacbruno
Copy link
Owner

I just tried

cd myblog
./marmite --watch --serve . /tmp/blog

And it worked using marmite 0.2.5

I also tried to invert the position of arguments and all worked.

@neiesc
Copy link

neiesc commented Apr 15, 2025

Hi @rochacbruno If I use the same folder like:
marmite --watch --serve . site?
https://i.imgur.com/gKb2rXl.gif

@rochacbruno
Copy link
Owner

Ohh @neiesc you found a bug, when you use the same folder it enters in an endless loop because the generated site counts as a change.

I think we need to address that on

marmite/src/site.rs

Lines 241 to 263 in 4b14084

hotwatch
.watch(watch_folder, move |event: Event| match event.kind {
EventKind::Create(_) | EventKind::Modify(_) | EventKind::Remove(_) => {
info!("Change detected. Rebuilding site...");
rebuild();
}
_ => {}
})
.expect("Failed to watch the input folder!");
info!("Watching for changes in folder: {}", input_folder.display());
// Keep the thread alive for watching
if serve {
info!("Starting built-in HTTP server...");
server::start(bind_address, &Arc::clone(output_folder));
} else {
loop {
std::thread::sleep(std::time::Duration::from_secs(1));
}
}
}
}

Make the output folder to be ignored when located in the same folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants