Batch processors

Questions, tips and tricks and techniques for scripting in Servoy

Postby Pierre-andre » Fri Aug 31, 2007 2:36 pm

Hehe :wink:

Oki thanks
Pierre-andre
 
Posts: 55
Joined: Mon Aug 20, 2007 9:31 am

Postby ROCLASI » Fri Aug 31, 2007 2:40 pm

IT2Be wrote:Glad you saw it! Did not want to correct you again :lol:


:P
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Postby pbakker » Fri Aug 31, 2007 2:43 pm

You were both too late... :twisted:
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby axterics » Mon Apr 07, 2008 12:09 pm

IT2Be wrote:The only thing you need to know/realize that this 'eats' one client license!


The licence is eaten always? Only when the headless client perform the cronjob or always when the headless client is started (in a production server = always)?
axterics
 
Posts: 122
Joined: Wed Feb 07, 2007 9:44 am
Location: Verona, Italy

Postby Jan Aleman » Mon Apr 07, 2008 12:14 pm

axterics wrote:
IT2Be wrote:The only thing you need to know/realize that this 'eats' one client license!


The licence is eaten always? Only when the headless client perform the cronjob or always when the headless client is started (in a production server = always)?


Technically it is running at all times so yes it eats a license. You could overcome this by using external schedulers but unless you have a lot of free time (as in free beer) it's more economical to buy a license.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby IT2Be » Mon Apr 07, 2008 12:14 pm

The batchprocessor is fired up when the server starts and as long as it is alive (server down or manual quit via server pages) there is a client.
Which makes sense...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re:

Postby rogel » Tue Sep 13, 2011 2:19 am

Pierre-andre wrote:At the moment, the server is working on Windows. But this method have to work with Linux and Mac OS/X.

In first, I wanted to create a stored procedure in PostgreSQL and executed it from servoy. But Postres don't allow to create Procedure, only function. Unfortunately I can't execute a REINDEX, PG_DUMP OR VACUUM command on database in function because "REINDEX cannot be executed inside a transaction block."
http://www.postgresql.org/docs/8.2/inte ... index.html


So I choosed to use cronjob. I created a Startup script :
var jobname = "backup"
var cronTimings = "* 00 22 * * ?"
var startDate = new Date()
var endDate = new Date(startDate.getFullYear()+50,startDate.getMonth(),startDate.getDate())
var args = new Array(directory_postgres,directory_for_backup)

plugins.scheduler.addCronJob(jobname, cronTimings, globals.Backup_DB,startDate,endDate,args)


The method backup:
var directory_postgres = arguments[0]
var directory_for_backup= arguments[1]

//Returns the name of the operating system
var osname = application.getOSName();

if(osname.indexOf("Windows",0)>-1){

var file = plugins.file.convertToJSFile(directory_postgres +"/vacuumdb.exe")
if(file.exists())
application.executeProgram(directory_postgres +"/vacuumdb.exe","-h","localhost","-p","5432","-U","postgres","-d","sopavet")

var file = plugins.file.convertToJSFile(directory_postgres +"/reindexdb.exe")
if(file.exists())
application.executeProgram(directory_postgres +"/reindexdb.exe","-h","localhost","-p","5432","-U","postgres","-d","sopavet"

var file = plugins.file.convertToJSFile(directory_postgres +"/pg_dump.exe")
if(file.exists())
application.executeProgram(directory_postgres +"/pg_dump.exe","-i","-h","localhost","-p","5432","-U","postgres","-F","t","-f","\""directory_for_backup+"/database_save.backup\"","sopavet"

}


I have to add security rules with postgres's user and complete this method for Linux and Mac OS/X.

It's work fine on Windows XP with Postgres 8.1, but I didn't know that batch process use one client license :shock:.So I have to find another way to backup my database.


I have the same requirement however i need to pass "where condition"(e.g. usderid='xyz'). I believe I cannot use pgdump. =( I would need to do it the hard way. Can you advice if my steps in doing the backup_db method is correct?
1. acquire lock in the database during the process
2. select all the tables
3. for each table
loadrecords
for each record
create the insert statement
write in <tablename>.sql file
4. release the lock

thanks in advance.
rogel
 
Posts: 264
Joined: Mon Jul 04, 2011 9:09 am

Re: Batch processors

Postby Jan Aleman » Tue Sep 13, 2011 9:36 am

Have you considered using pgAgent? Sounds like less work to me.

http://www.postgresonline.com/journal/a ... ckups.html
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Re: Batch processors

Postby rogel » Tue Sep 13, 2011 2:54 pm

Jan Aleman wrote:Have you considered using pgAgent? Sounds like less work to me.

http://www.postgresonline.com/journal/a ... ckups.html


Thank you for the suggestion but I am not allowed to use other interface of other software application.
rogel
 
Posts: 264
Joined: Mon Jul 04, 2011 9:09 am

Previous

Return to Methods

Who is online

Users browsing this forum: No registered users and 17 guests

cron