FreeSWITCH load CDR CSV to Mysql, theoretical problem?
I'm using the script on: http://convergence.pk/freeswitch-load-cdr-csv-to-mysql.html which also can be found on the http://wiki.freeswitch.org/wiki/Mod_cdr_csv. I'm having in running every 5 minute. And everything works. But I do have some concern. What if the job suddenly takes more than 5 minutes to complete and another job start, doing the same thing. Couldn't that be a problem and can it be fixed?
On 25/01/12 13:25, Henrik Aagaard Sørensen wrote:
What if the job suddenly takes more than 5 minutes to complete and another job start, doing the same thing.
Couldn't that be a problem and can it be fixed?
Use Perls Fcntl module to ensure the program can only be running once - if a second instance starts it will quit immediately and the next scheduled run will pick up the remaining files. Of course, if this happens to often you will take a long time to catch up with the importing. At the beginning of the script (after 'use File::Copy;') add: use Fcntl qw(:flock); unless (flock(DATA, LOCK_EX|LOCK_NB)) { exit; print "$0 is already running. Exiting.\n"; exit(1); } and at the very end add: __DATA__ This exists so flock() code above works. DO NOT REMOVE THIS DATA SECTION. Regards,
Should __DATA__ be at the very very end, after exit 0; So: exit 0; __DATA__ On Wed, Jan 25, 2012 at 8:07 PM, Paul Cupis <paul@cupis.co.uk> wrote:
On 25/01/12 19:06, Paul Cupis wrote:
unless (flock(DATA, LOCK_EX|LOCK_NB)) { exit; print "$0 is already running. Exiting.\n"; exit(1); }
Er. editing the commands inside the braces above to suit. :)
Regards,
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
http://search.cpan.org/dist/Proc-Pidfile/Pidfile.pm On Jan 25, 2012, at 2:06 PM, Paul Cupis wrote:
On 25/01/12 13:25, Henrik Aagaard Sørensen wrote:
What if the job suddenly takes more than 5 minutes to complete and another job start, doing the same thing.
Couldn't that be a problem and can it be fixed?
Use Perls Fcntl module to ensure the program can only be running once - if a second instance starts it will quit immediately and the next scheduled run will pick up the remaining files.
Of course, if this happens to often you will take a long time to catch up with the importing.
At the beginning of the script (after 'use File::Copy;') add:
use Fcntl qw(:flock); unless (flock(DATA, LOCK_EX|LOCK_NB)) { exit; print "$0 is already running. Exiting.\n"; exit(1); }
and at the very end add:
__DATA__ This exists so flock() code above works. DO NOT REMOVE THIS DATA SECTION.
participants (3)
-
Henrik Aagaard Sørensen
-
Michael Jerris
-
Paul Cupis