trilbymedia / grav-plugin-git-sync

Collaboratively Synchronize your Grav `user` folder hosted on GitHub, BitBucket or GitLab
Apache License 2.0
243 stars 58 forks source link

Scheduler support broken (fatal: Authentication failed for...) #209

Closed kees-closed closed 2 years ago

kees-closed commented 2 years ago

Hi, in the admin-panel I've enabled a cron to make sure the configurations are kept up2date in git. However, this cron fails for a while already in the overview with fatal: Authentication failed for {{ git_repo_details }}.

I thought this would be related to my configuration. But launching the git-sync from the admin-panel works without issues. The status in the admin-panel is clear, the action succeeded. When checking the git repo this is indeed the case. So username, password and git repo work fine.

In my config file I have the following:

sync:
  on_save: true
  on_delete: true
  on_media: true
  cron_enable: true
  cron_at: '0 12,23 * * *'

Which corresponds with what's shown in the admin-panel of the plugin and the scheduler overview. Although also the scheduler overview in the admin-panel shows the same error fatal: Authentication failed for {{ git_repo_details }}.

When consulting the scheduler on the command line I see the following:

bin/grav scheduler -vd

Job Details
===========

┌─────────────────────┬──────────────────┬──────────────────┬──────────────────────────────────────────────┐
│ Job ID              │ Last Run         │ Next Run         │ Errors                                       │
├─────────────────────┼──────────────────┼──────────────────┼──────────────────────────────────────────────┤
│ tntsearch-index     │ 2021-12-14 05:01 │ 2021-12-15 05:01 │ /usr/bin/env: php: No such file or directory │
│ email-flushqueue    │ 2021-12-14 10:41 │ 2021-12-14 10:42 │ None                                         │
│ default-site-backup │ 2021-12-14 03:00 │ 2021-12-15 03:00 │ None                                         │
│ cache-purge         │ 2021-12-14 04:00 │ 2021-12-15 04:00 │ None                                         │
│ cache-clear         │ 2021-12-14 04:30 │ 2021-12-15 04:30 │ None                                         │
└─────────────────────┴──────────────────┴──────────────────┴──────────────────────────────────────────────┘

As can be seen, there is no mention of git-sync. While it is shown in the admin-panel. Perhaps the error that's triggered is because of some mismatch in adding the proper configuration in the scheduler?

git-sync is enabled in the settings and admin-panel:

status:
  tntsearch-index: enabled
  email-flushqueue: enabled
  git-sync: enabled
  cache-purge: enabled
  cache-clear: enabled
  default-site-backup: enabled

The last successful run via the scheduler was on Wed Nov 24 23:00:07 2021 UTC for git-sync. Maybe I upgraded to the latest version of June at that point. Can someone double check if this is reproducible? I already removed the plugin and any other user defined configs and started from scratch.

mahagr commented 2 years ago

Make sure to check where the configuration is being saved. For CLI it should be in /user/config/plugins/git-sync but admin may save it into /user/env/hostname.com/... or /user/hostname.com/...

mahagr commented 2 years ago

So either move the configuration to the main config folder or use --env hostname.com parameter in CLI (not 100% sure if it works, it should IMHO).

kees-closed commented 2 years ago

Should manual intervention be needed when the admin panel is used? I reinstalled the plugin twice and removed all configs before installing it again. After running the setup wizard for git-sync the cron job still doesn't work. Sure, I might be able to fix it with the CLI, but if I have to do that, then I would conclude that there is a bug in the admin panel.

The config file is indeed where it should be when using the admin panel:

find . -type f -name *git-sync*
./user/plugins/git-sync/css-compiled/git-sync-icon.css
./user/plugins/git-sync/css-compiled/git-sync.css
./user/plugins/git-sync/git-sync.php
./user/plugins/git-sync/git-sync.yaml
./user/plugins/git-sync/scss/git-sync.scss
./user/hostname/config/plugins/git-sync.yaml

But the cron job is not running, while it is enabled in the cron config and the cron details are listed in the git-sync config file.

kees-closed commented 2 years ago

A reinstall of Grav fixed the issue.