Providing an editing interface is one half of the battle but it's pretty straightforward. There are already apps out there to provide editing of templates and media files so it's pretty much just an extension of that.
The hardest part is restarting the server which would have to happen in order for the new code to be compiled. I don't think there's a way to do this from within the server so here's how I would do it:
- When you make an edit, create a new file in the project root. eg an empty file called restart.
- Write an bash script to look for that file, if it exists, restart the site and delete the file.
- Cron the script to run once every 10 seconds. It shouldn't use any meaningful resources.
One serious issue is if you introduce bugs. You could test-compile (ie running the dev-server before you restart the site and check the input) but that's not very robust and you could easily end up in a situation where you lose access to the site.
As that's the case, it might be wise to set up the editor as a completely separate site so you're never locked out...