pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Spaawn another process
6+ messages / 5 participants
[nested] [flat]

* Re: Spaawn another process
@ 2002-11-06 06:09  YC Nyon <ycnyon@pd.jaring.my>
  0 siblings, 3 replies; 6+ messages in thread

From: YC Nyon @ 2002-11-06 06:09 UTC (permalink / raw)
  To: pgsql-php

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 </html> tag. Would that be the
way?

TIA
Nyon




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Spaawn another process
@ 2002-11-06 19:16  scott.marlowe <scott.marlowe@ihs.com>
  parent: YC Nyon <ycnyon@pd.jaring.my>
  2 siblings, 0 replies; 6+ messages in thread

From: scott.marlowe @ 2002-11-06 19:16 UTC (permalink / raw)
  To: YC Nyon <ycnyon@pd.jaring.my>; +Cc: pgsql-php

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 </html> 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?




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Spaawn another process
@ 2002-11-06 19:50  Michael Upchurch <mike@partner2partner.net>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Upchurch @ 2002-11-06 19:50 UTC (permalink / raw)
  To: YC Nyon <ycnyon@pd.jaring.my>; pgsql-php

"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 </html> tag. Would that be the
>way?

Use register_shutdown_function() to run a function which exec's the
command.  This turns lose of the browser while the command executes.  Of
course, you will lose the ability to poll the status of the command unless
you build this into your function.

-- 
Michael J. Upchurch
Partner2Partner Communications, LLC



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Spaawn another process
@ 2002-11-06 20:00  Michael Upchurch <mike@partner2partner.net>
  0 siblings, 0 replies; 6+ messages in thread

From: Michael Upchurch @ 2002-11-06 20:00 UTC (permalink / raw)
  To: YC Nyon <ycnyon@pd.jaring.my>; pgsql-php

"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 </html> tag. Would that be the
>way?

Use register_shutdown_function() to run a function which exec's the
command. This turns lose of the browser while the command executes. Of
course, you will lose the ability to poll the status of the command unless
you build this into your function.

-- 
Michael J. Upchurch
Partner2Partner Communications, LLC



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Spaawn another process
@ 2002-11-07 09:42  Andrew McMillan <andrew@catalyst.net.nz>
  parent: YC Nyon <ycnyon@pd.jaring.my>
  2 siblings, 0 replies; 6+ messages in thread

From: Andrew McMillan @ 2002-11-07 09:42 UTC (permalink / raw)
  To: YC Nyon <ycnyon@pd.jaring.my>; +Cc: pgsql-php

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 </html> 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/ 
---------------------------------------------------------------------




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Spaawn another process
@ 2002-11-07 09:53  Papp Gyozo <pgerzson@freestart.hu>
  parent: YC Nyon <ycnyon@pd.jaring.my>
  2 siblings, 0 replies; 6+ messages in thread

From: Papp Gyozo @ 2002-11-07 09:53 UTC (permalink / raw)
  To: YC Nyon <ycnyon@pd.jaring.my>; pgsql-php

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 </html> 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2002-11-07 09:53 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-06 06:09 Re: Spaawn another process YC Nyon <ycnyon@pd.jaring.my>
2002-11-06 19:16 ` scott.marlowe <scott.marlowe@ihs.com>
2002-11-07 09:42 ` Andrew McMillan <andrew@catalyst.net.nz>
2002-11-07 09:53 ` Papp Gyozo <pgerzson@freestart.hu>
2002-11-06 19:50 Re: Spaawn another process Michael Upchurch <mike@partner2partner.net>
2002-11-06 20:00 Re: Spaawn another process Michael Upchurch <mike@partner2partner.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox