[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-devel] web update hooks & script
From: |
Thomas Keller |
Subject: |
[Monotone-devel] web update hooks & script |
Date: |
Fri, 26 Jan 2007 16:45:58 +0100 |
User-agent: |
Thunderbird 1.5.0.9 (X11/20060911) |
Hi all!
Another nice little script from me, this time it deals with updating a
website (or any other resource) as soon as revisions or certs for a
particular branch, on which the resource is based, arrive.
All you need then is a running mtn server process on the same server and
everything should run smoothly.
If you find this good enough for contrib/, let me know and I'll put it
there. Otherwise are patches welcome =)
Thomas.
--
ICQ: 85945241 | SIP: 1-747-027-0392 | http://www.thomaskeller.biz
> Guitone, a frontend for monotone: http://guitone.thomaskeller.biz
> Music lyrics and more: http://musicmademe.com
_branch = "my.target.branch"
_updater = "/path/to/update.sh"
_sessions = {}
-- fixme: only session_id is set, so we can't check the server's role or sync
type here!
-- this seems to be some weird bug with monotone (tested with 0.31)
function note_netsync_start (session_id, my_role, sync_type, remote_host,
remote_keyname, includes, excludes)
print("netsync_start: starting netsync communication")
_sessions[session_id] = 0
end
function note_netsync_revision_received (new_id, revision, certs, session_id)
if _sessions[session_id] == nil then
print("revision_received: no session present")
return
end
for i,cert in ipairs(certs) do
if cert["name"] == "branch" and cert["value"] == _branch then
print("revision_received: found another interesting
revision")
_sessions[session_id] = _sessions[session_id] + 1
end
end
end
-- check if an interesting cert has arrived due to propagate
function note_netsync_cert_received (rev_id, key, name, value, session_id)
if _sessions[session_id] == nil then
print("cert_received: no session present")
return
end
if name == branch and value == _branch then
print("cert_received: found another interesting cert")
_sessions[session_id] = _sessions[session_id] + 1
end
end
function note_netsync_end (session_id, status, bytes_in, bytes_out, certs_in,
certs_out, revs_in, revs_out, keys_in, keys_out)
if _sessions[session_id] == nil then
print("netsync_end: no session present")
return
end
-- fixme: we should check status for being != 200, but as above, it
seems as this is not set
-- if no interesting revisions arrived, skip the update
if _sessions[session_id] == 0 then
print("netsync_end: no interesting revisions/certs received")
return
end
_sessions[session_id] = nil
print("netsync_end: running update script")
spawn(_updater)
end
update.sh
Description: application/shellscript
- [Monotone-devel] web update hooks & script,
Thomas Keller <=