Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #4383 > unrolled thread
| Started by | John Drako <jbravo556@gmail.removethis.com> |
|---|---|
| First post | 2012-01-09 20:32 -0500 |
| Last post | 2012-01-10 17:39 +0100 |
| Articles | 10 — 7 participants |
Back to article view | Back to comp.lang.php
Running function in the background? John Drako <jbravo556@gmail.removethis.com> - 2012-01-09 20:32 -0500
Re: Running function in the background? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-09 20:43 -0500
Re: Running function in the background? The Natural Philosopher <tnp@invalid.invalid> - 2012-01-10 02:06 +0000
Re: Running function in the background? Michael Joel <no@please.com> - 2012-01-09 21:50 -0500
Re: Running function in the background? Luuk <Luuk@invalid.lan> - 2012-01-10 11:50 +0100
Re: Running function in the background? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-10 07:52 -0500
Re: Running function in the background? Captain Paralytic <paul_lautman@yahoo.com> - 2012-01-10 02:03 -0800
Re: Running function in the background? John Drako <jbravo556@gmail.removethis.com> - 2012-01-11 08:40 -0500
Re: Running function in the background? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-01-10 17:29 +0100
Re: Running function in the background? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-01-10 17:39 +0100
| From | John Drako <jbravo556@gmail.removethis.com> |
|---|---|
| Date | 2012-01-09 20:32 -0500 |
| Subject | Running function in the background? |
| Message-ID | <jeg4fm02opn@news1.newsguy.com> |
I have a site where users can download files, and I want to enable the users to request files by email. Some of those files are big (not too big for email attachements). What I would like to have the user be able to do is to click on a file and have it emailed to him, but the user shouldn't have to wait for the emailing function to finish (tens of seconds some time) and continue browsing and clicking on other files to email or even leave the site confident that they'll receive the files in their email later. So I would like the emailing functionality to happen in the background and independent from the connection to the browser. Is this possible? Is it doable in PHP directly?
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-01-09 20:43 -0500 |
| Message-ID | <jeg53c$kb2$1@dont-email.me> |
| In reply to | #4383 |
On 1/9/2012 8:32 PM, John Drako wrote: > I have a site where users can download files, and I want to enable the > users to request files by email. Some of those files are big (not too > big for email attachements). > > What I would like to have the user be able to do is to click on a file > and have it emailed to him, but the user shouldn't have to wait for the > emailing function to finish (tens of seconds some time) and continue > browsing and clicking on other files to email or even leave the site > confident that they'll receive the files in their email later. > > So I would like the emailing functionality to happen in the background > and independent from the connection to the browser. > > Is this possible? Is it doable in PHP directly? > You can do it by executing a system script (i.e. bash) in the background. But you have to have privileges to do it, which are not normally possible on shared hosting. What's the problem with just downloading the file? Users are used to downloading big files (some I've had to get are > 1.8GB GPS maps). Additionally, it might be ok for your system to send a huge file - but may NOT be ok for the user's mail server to ACCEPT a big file. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2012-01-10 02:06 +0000 |
| Message-ID | <jeg6f2$7j9$1@news.albasani.net> |
| In reply to | #4383 |
John Drako wrote: > I have a site where users can download files, and I want to enable the > users to request files by email. Some of those files are big (not too > big for email attachements). > > What I would like to have the user be able to do is to click on a file > and have it emailed to him, but the user shouldn't have to wait for the > emailing function to finish (tens of seconds some time) and continue > browsing and clicking on other files to email or even leave the site > confident that they'll receive the files in their email later. > > So I would like the emailing functionality to happen in the background > and independent from the connection to the browser. > > Is this possible? Is it doable in PHP directly? > it happens anyway. the 'program running in the background' is the mailer daemon. When you invoke php mail() function all that does is validate the addresses and queue the e-mail. sendmail (or whatever) then forks to do the actual sending as a separate process. (or not if you use the queue only functionality: In that case the mail will get sent in the next queue run - maybe every hour typically) Now making up an external file as the message body is trivial, but making it an attachment is not. But even fairly large attachments - 5-10MB - is not too hard. And won't tie up php too much o for too long.
[toc] | [prev] | [next] | [standalone]
| From | Michael Joel <no@please.com> |
|---|---|
| Date | 2012-01-09 21:50 -0500 |
| Message-ID | <9k9ng7h2c1vp889pgfoeh7eko566amljg7@4ax.com> |
| In reply to | #4383 |
On Mon, 9 Jan 2012 20:32:43 -0500, John Drako <jbravo556@gmail.removethis.com> wrote: >I have a site where users can download files, and I want to enable the >users to request files by email. Some of those files are big (not too >big for email attachements). > >What I would like to have the user be able to do is to click on a file >and have it emailed to him, but the user shouldn't have to wait for the >emailing function to finish (tens of seconds some time) and continue >browsing and clicking on other files to email or even leave the site >confident that they'll receive the files in their email later. > >So I would like the emailing functionality to happen in the background >and independent from the connection to the browser. > >Is this possible? Is it doable in PHP directly? Just an idea - if it sounds dumb just ignore me :) If nothing else works better. Instead of needing privileges do run system scrips - couldn't you create a cron job for a PHP script that sends emails to all records in a database? When the user clicks the link it simply adds their email address and fiel to email to the database. When the cron job runs it sends out an email with the files linked with it. just a quick thought Mike
[toc] | [prev] | [next] | [standalone]
| From | Luuk <Luuk@invalid.lan> |
|---|---|
| Date | 2012-01-10 11:50 +0100 |
| Message-ID | <cphtt8-2el.ln1@luuk.invalid.lan> |
| In reply to | #4386 |
On 10-01-2012 03:50, Michael Joel wrote: > On Mon, 9 Jan 2012 20:32:43 -0500, John Drako > <jbravo556@gmail.removethis.com> wrote: > >> I have a site where users can download files, and I want to enable the >> users to request files by email. Some of those files are big (not too >> big for email attachements). >> >> What I would like to have the user be able to do is to click on a file >> and have it emailed to him, but the user shouldn't have to wait for the >> emailing function to finish (tens of seconds some time) and continue >> browsing and clicking on other files to email or even leave the site >> confident that they'll receive the files in their email later. >> >> So I would like the emailing functionality to happen in the background >> and independent from the connection to the browser. >> >> Is this possible? Is it doable in PHP directly? > > Just an idea - if it sounds dumb just ignore me :) > > If nothing else works better. Instead of needing privileges do run > system scrips - couldn't you create a cron job for a PHP script that > sends emails to all records in a database? > > When the user clicks the link it simply adds their email address and > fiel to email to the database. When the cron job runs it sends out an > email with the files linked with it. > > just a quick thought > Mike i like this solution, but i cannot find the 'i like'-button ;) -- Luuk
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-01-10 07:52 -0500 |
| Message-ID | <jehcb6$rra$1@dont-email.me> |
| In reply to | #4386 |
On 1/9/2012 9:50 PM, Michael Joel wrote: > On Mon, 9 Jan 2012 20:32:43 -0500, John Drako > <jbravo556@gmail.removethis.com> wrote: > >> I have a site where users can download files, and I want to enable the >> users to request files by email. Some of those files are big (not too >> big for email attachements). >> >> What I would like to have the user be able to do is to click on a file >> and have it emailed to him, but the user shouldn't have to wait for the >> emailing function to finish (tens of seconds some time) and continue >> browsing and clicking on other files to email or even leave the site >> confident that they'll receive the files in their email later. >> >> So I would like the emailing functionality to happen in the background >> and independent from the connection to the browser. >> >> Is this possible? Is it doable in PHP directly? > > Just an idea - if it sounds dumb just ignore me :) > > If nothing else works better. Instead of needing privileges do run > system scrips - couldn't you create a cron job for a PHP script that > sends emails to all records in a database? > > When the user clicks the link it simply adds their email address and > fiel to email to the database. When the cron job runs it sends out an > email with the files linked with it. > > just a quick thought > Mike A good idea if you can create cron jobs. However, it has its down sides, also. Either you have to run the cron job quite often, taking system resources when there is no work to do, or the user has to wait a while before receiving the file. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Captain Paralytic <paul_lautman@yahoo.com> |
|---|---|
| Date | 2012-01-10 02:03 -0800 |
| Message-ID | <ac12a4d2-7ef6-4468-a6d6-8ba2ee5b0381@k29g2000vbl.googlegroups.com> |
| In reply to | #4383 |
On Jan 10, 1:32 am, John Drako <jbravo...@gmail.removethis.com> wrote: > confident that they'll receive the files in their email later. as has been pointed out, it is this requirement that may well not be met by email, particularly in the case of very large files.
[toc] | [prev] | [next] | [standalone]
| From | John Drako <jbravo556@gmail.removethis.com> |
|---|---|
| Date | 2012-01-11 08:40 -0500 |
| Message-ID | <jek3fq029vg@news1.newsguy.com> |
| In reply to | #4388 |
On Tue, 10 Jan 2012 05:03:34 -0500, Captain Paralytic wrote (in article <ac12a4d2-7ef6-4468-a6d6-8ba2ee5b0381@k29g2000vbl.googlegroups.com>): > On Jan 10, 1:32 am, John Drako <jbravo...@gmail.removethis.com> wrote: >> confident that they'll receive the files in their email later. > > as has been pointed out, it is this requirement that may well not be > met by email, particularly in the case of very large files. Thanks everybody for the feedback. The site handles ebooks and emailing ebooks is a way to overcome a bug in the Kindle Fire to open .mobi files downloaded directly onto it from sources other than Amazon. After careful consideration and analysis of the user base needs, I've opted to not seek a solution to run it in the background. The few readers that need this know that they'll have to wait. So I implemented it as normal with PHPMailer. As I control the server farm as well as the contents engine, I could have executed any solution, but it wasn't worth the effort in the end.
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-01-10 17:29 +0100 |
| Message-ID | <9n37aqF2t3U1@mid.uni-berlin.de> |
| In reply to | #4383 |
Am 10.01.2012 02:32, schrieb John Drako: > I have a site where users can download files, and I want to enable the > users to request files by email. Some of those files are big (not too > big for email attachements). > > What I would like to have the user be able to do is to click on a file > and have it emailed to him, but the user shouldn't have to wait for the > emailing function to finish (tens of seconds some time) and continue > browsing and clicking on other files to email or even leave the site > confident that they'll receive the files in their email later. > > So I would like the emailing functionality to happen in the background > and independent from the connection to the browser. > > Is this possible? Is it doable in PHP directly? > Damn good question. As to do it in PHP directly I find http://stackoverflow.com/questions/317392/is-process-forking-in-php-apache-a-good-idea with links to other questions of this type. I never did forking in the web server because I consider it dangerous, it can kill or hang it or send it into a loop. I did it like Mike suggested, with cron-jobs running every 10 minutes, and even with my own daemon "watching" a job file. For shared hosting mostly not doable.. /Str.
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-01-10 17:39 +0100 |
| Message-ID | <9n37ucF7l8U1@mid.uni-berlin.de> |
| In reply to | #4401 |
Am 10.01.2012 17:29, schrieb M. Strobel: > Am 10.01.2012 02:32, schrieb John Drako: >> I have a site where users can download files, and I want to enable the >> users to request files by email. Some of those files are big (not too >> big for email attachements). >> >> What I would like to have the user be able to do is to click on a file >> and have it emailed to him, but the user shouldn't have to wait for the >> emailing function to finish (tens of seconds some time) and continue >> browsing and clicking on other files to email or even leave the site >> confident that they'll receive the files in their email later. >> >> So I would like the emailing functionality to happen in the background >> and independent from the connection to the browser. >> >> Is this possible? Is it doable in PHP directly? >> > Damn good question. > > As to do it in PHP directly I find > http://stackoverflow.com/questions/317392/is-process-forking-in-php-apache-a-good-idea > with links to other questions of this type. > > I never did forking in the web server because I consider it > dangerous, it can kill or hang it or send it into a loop. > > I did it like Mike suggested, with cron-jobs running every 10 > minutes, and even with my own daemon "watching" a job file. For > shared hosting mostly not doable.. > > /Str. Addition: If the at command works okay in your server you can schedule jobs in your script. I do it in a cgi script calling a shell script, and this does echo /usr/local/bin/webblock remove $2 | /usr/bin/at now + 5 minutes 2>/dev/null
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web