aboutsummaryrefslogtreecommitdiff
path: root/doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn
diff options
context:
space:
mode:
authorspalax <spalax@web>2013-12-18 13:06:18 -0400
committeradmin <admin@branchable.com>2013-12-18 13:06:18 -0400
commit9c5acd044851f1d1ff193628a1205d4fbe692bc6 (patch)
tree01f08342b64e6423dfc4aae69bb925c7869e5c9b /doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn
parent800b03c9ea33c7b41591b1a679c6328d52b76a18 (diff)
downloadikiwiki-9c5acd044851f1d1ff193628a1205d4fbe692bc6.tar
ikiwiki-9c5acd044851f1d1ff193628a1205d4fbe692bc6.tar.gz
Prevent a deadlock
Diffstat (limited to 'doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn')
-rw-r--r--doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn20
1 files changed, 16 insertions, 4 deletions
diff --git a/doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn b/doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn
index e971a8339..baf7ac6c8 100644
--- a/doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn
+++ b/doc/tips/Hosting_Ikiwiki_and_master_git_repository_on_different_machines.mdwn
@@ -119,14 +119,26 @@ repository.
## Configure the git repository (on the git machine) to update the wiki after a push
-- Add in the `post-receive` hook (file `SITE.git/hooks/post-receive`):
+Add in the `post-receive` hook (file `SITE.git/hooks/post-receive`):
- wget "http://WIKI-URL/ikiwiki.cgi?do=ping" -O /dev/stdout
+ git log -1 --format=format:%ae HEAD | grep -e '@web$' -e 'USER@HOST' || wget "http://WIKI-URL/ikiwiki.cgi?do=ping" -O /dev/stdout
- If your wiki is password protected, use:
+If your wiki is password protected, use:
- wget "http://LOGIN:PASSWORD@WIKI-URL/ikiwiki.cgi?do=ping" -O /dev/stdout
+ git log -1 --format=format:%ae HEAD | grep -e '@web$' -e 'USER@HOST' || wget "http://LOGIN:PASSWORD@WIKI-URL/ikiwiki.cgi?do=ping" -O /dev/stdout
+The bit before `wget` is here to prevent updating the wiki while it is
+updating, which can lead to a deadlock. Indeed, when the wiki is edited via
+web, or a tag page is automatically added, IkiWiki pushes the changes to the
+Git machine. Then, the hook on this latter machine tries to pull changes from
+the IkiWiki machine, and here is the deadlock. Explanations of the command:
+
+* `git log -1 --format=format:%ae HEAD`: Looks for the user name of the
+ latest commit.
+* `grep -e '@web$' -e 'USER@HOST': Check whether this last commit was pushed
+ from the IkiWiki machine (change `USER@HOST` to the appropriate string).
+* `wget ...`: If the last commit does not come from the IkiWiki machine
+ (which means it comes from another machine), update the wiki.
## Going further