|
From: | Stephen Rosen |
Subject: | Re: [Fab-user] Saving state? (shared memory space?) |
Date: | Fri, 5 Apr 2013 08:53:53 -0500 |
I think this is a feature slated for fabric 2.0, done by locking and sharing env. Devs could answer this better than I. I would consider using a mysql db ahead of sqlite, but it largely depends on what you are doing.
It's a bit messy, but I actually keep a directory on my fabric server for each host and have them write to logfiles in those directories. Distinct tasks can then operate on those logfiiles, and we can even stitch them together with meta tasks that have @run_once and invoke execute. Not pretty, but it works.
This covers most of my use cases, but one application calls out to a mysql db on a remote server.
If it's just for logging, I recommend the family of directories. I've never had a problem with it, although you have to be careful not to generate spurious directories when someone mistypes a hostname.
Not sure if anyone actually keeps a DB on their fabric server that tracks host metadata, state, etc, but I'd be curious about how well that works.
Hope this helped,
-Stephen
Sent by Android
Hello fellow fabric users.During parallel runs, I would like to be able to collect information in some sort of shared memory space to review after I'm done.This seems to be tricky when running in parallel. (assumably due to the threading)Example use cases:tracking success vs failed counts after a runstuffing output in a tidy coalesced log after the job runsI tried stuffing the output in to env, but that's apparently not a shared global space....Any guidance on how this might be done?(calling out to a DB/sqllite or even a lockfile wrapped pickle seem like passable solutions, but I'm hoping there's an easier way to collect data during a parallel run and summarize it later...)Help?Is there a cleanup method on exit where I should be looking at env?Thanks,Joel Krauskacode snippet:from fabric.api import *from fabric.colors import red, greenenv.mydata={}env.failcount=0env.goodcount=0@taskdef mytask():with settings(hide('warnings', 'running', 'stdout', 'stderr','output'),):result=run("uname")print '-'*80print env.host_string,if result.failed:print red('FAILED')env.failcount+=1else:print green('OK')env.goodcount+=1print resultenv.mydata[env.host_string]=str(result)print env.mydata# These aren't holding anything useful...print env.mydataprint env.failcountprint env.goodcount
_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user
[Prev in Thread] | Current Thread | [Next in Thread] |