Forum: Cfengine Help Subject: Re: Is locking broken, or do I misunderstand? Author: sauer Link to topic: https://cfengine.com/forum/read.php?3,22374,22376#msg-22376
neilhwatson Wrote: ------------------------------------------------------- > I'm not certain that the action part can be at the > method level. You might try placing that in the > method bundle at the appropriate promises. Well, action is listed as a body for all agent promises, and the if_elapsed part does seem to work; it's just the "don't start this up if another one's already running" part that seems to be not working the way I'd expect. The whole reason I need a lock at the method level boils down to the inability to do an edit lines promise recursively on a directory. I'm trying really hard not to rant about my feelings on the decision to arbitrarily impose that limit, but it's caused me *substantial* diffculty. I need to go over a directory structure which consists of 1104 directories which mostly go 2-3 levels down (but there's no restriction that they must be at that depth) and ensure that all files which end with .cgi or .pl and which have #!.*perl in the first line are using "#!/usr/bin/perl -U". Say I provide a list of directories, and use a files promise to do something like "$(dir)/.*\.(cgi|pl)", and then I put the action constraint on that (I'm actually not sure that this works either, as there's some note about how you can only edit files in a directory if you specify the beginning of the filename instead of the end, or something like that - I seem to recall testing that and being dissapointed). The same thing will happen; evaluation of the promises will take too long, so a subsequent cf-agent invocation will get into the method, run the find command which locates all of the directories, and start working on the next set of directories. This starts causing disk contention, which slows the previous invocation down. In the ideal case, this still takes around 1/2 hour to complete, so over that time period, I'll eventually have at least 6 cf-agent processes started up, all contending for disk, making stuff take even longer. What I'm after is a way for a single process to plod along in the background, editing files sequentially and not interferring with some other security-sensitive auditing tasks which really should be validated every ~5 minutes. :) I'm really thinking that the persistent class which gets set when this starts and cleared when it's done is gonna be my most effective mechanism, absent an inherent locking scheme. :/ _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine