Re: Spaawn another process

Re: Spaawn another process

am 06.11.2002 07:09:04 von YC Nyon

In my PHP page, I need to run a external program to insert map data into
Postgresql. However, the process is very slow (can be 10 mins). How do I
return a webpage telling the user that the process is running and permits
the user to browse the other parts of the web application.

My idea is to run the "exec();" after the tag. Would that be the
way?

TIA
Nyon


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: Spaawn another process

am 06.11.2002 20:16:08 von Scott Marlowe

On Wed, 6 Nov 2002, YC Nyon wrote:

> In my PHP page, I need to run a external program to insert map data into
> Postgresql. However, the process is very slow (can be 10 mins). How do I
> return a webpage telling the user that the process is running and permits
> the user to browse the other parts of the web application.
>
> My idea is to run the "exec();" after the tag. Would that be the
> way?

you should be able to do it like so:

exec('commandname args 2>1&');

You are running some flavor of unix, right?


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Spaawn another process

am 07.11.2002 10:42:33 von Andrew McMillan

On Wed, 2002-11-06 at 19:09, YC Nyon wrote:
> In my PHP page, I need to run a external program to insert map data into
> Postgresql. However, the process is very slow (can be 10 mins). How do I
> return a webpage telling the user that the process is running and permits
> the user to browse the other parts of the web application.
>
> My idea is to run the "exec();" after the tag. Would that be the
> way?

I would tend to not start it from PHP, but to write enough details into
a "queue" table which would be processed in sequence by a background
task.

This approach:

a) simplifies your PHP a bit,

b) avoids the issue of 'when' entirely,

c) lets you write status into the queue table and have a page that tells
them it's 50% done, or is next in the queue, or whatever,

and

d) makes the handling of 10, 20 or 30 minute jobs one which hits the
database serially, rather than in parallel (or you can control the
parallelism to a level your equipment can handle).


Cheers,
Andrew.
>
> TIA
> Nyon
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
--
------------------------------------------------------------ ---------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Survey for nothing with http://survey.net.nz/
------------------------------------------------------------ ---------


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: Spaawn another process

am 07.11.2002 10:53:27 von pgerzson

2002. november 6. 07:09 dátummal YC Nyon ezt írta:
| In my PHP page, I need to run a external program to insert map data
| into Postgresql. However, the process is very slow (can be 10 mins).
| How do I return a webpage telling the user that the process is
| running and permits the user to browse the other parts of the web
| application.
|
| My idea is to run the "exec();" after the tag. Would that be
| the way?

I think it's a wrong idea, there is a more sophisticated way to achive
this. For more information see register_shutdown_function() in the PHP
manual. (http://php.net/register_shutdown_function)
|
| TIA
| Nyon
|
|
| ---------------------------(end of
| broadcast)--------------------------- TIP 4: Don't 'kill -9' the
| postmaster

--
Papp, Gyõzõ
- pgerzson@freestart.hu

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org