pedroborges / kirby-autogit

⬢ Saves every change made via Kirby Panel to a Git repository
149 stars 23 forks source link

Site load is much slower when autogit is enabled #23

Closed fitzage closed 7 years ago

fitzage commented 7 years ago

I've put a lot of work into site optimization recently, and so it was painfully obvious that initial page load times were dramatically increased on my staging server with autogit installed.

As a quick diagnostic check, I ran top while loading pages, and it seems that every page load on the public site is waiting on a git command, which shouldn't be happening.

Related to this is occasional runtime exceptions when browsing the site, which means I really can't use the plugin at all at this point. But I think if the first one is fixed, that would fix the second one.

pedroborges commented 7 years ago

Thanks for reporting this @fitzage. Autogit should not slow down websites since its main feature requires the panel.

Thankfully the fix was easy, now the core of Autogit only runs when on the panel. The only feature that exists outside the panel is webhooks, the verification if the content directory has a remote repo now is done inside the webhook route.

Please try it out and let me know how it goes.

fitzage commented 7 years ago

Excellent! I will try to give it a shot this afternoon.

fitzage commented 7 years ago

@pedroborges related question: if I install this on production servers without the control panel, will the webhooks still work? Or will I need the whole control panel to be there also?

fitzage commented 7 years ago

OK, this does appear to solve the problem. Woohoo!

pedroborges commented 7 years ago

if I install this on production servers without the control panel, will the webhooks still work?

It should work without any issue. Webhooks depend on the autogit.webhook.secret option alone. Just make sure a secret key is set then try to access: yoursite.com/autogit/push?secret=SECRET_KEY or yoursite.com/autogit/pull?secret=SECRET_KEY

This is for accessing the webhook externally, as a way to backup you content frequently I recommend adding a cron job to run cd /site/path && git push origin master at the interval you feel appropriate.