I write module for Penny auctions (similar to swoopo.com). Many things are finished, but I have problem with bid butlers (more details).

I has made one function that scanned all auctions and bid butlers in relation with that auctions. I need to run that function in background, because it will sleep when it has nothing to do. Something like

function function_name() {
  // Array with control signals.
  $bid_butlers = get_bid_butles();

  // Variable that save time of end of auction that will be first end.
  $first_end_time = get_first_end_time();

  while(true) {
    $signals = get_signals();
    if($signals['exit'] === TRUE) {
      break;
    }

    if($signals['rescan'] === TRUE) {
      // Rescan database for new auctions or bid butlers.
      $bid_butlers = get_bid_butles();
      $first_end_time = get_first_end_time();
    }

    if($first_end_time - time() < 10) {
      // Then start to place bids for auctions that have less than 10s to the end.

    }

    sleep(1);

  }
}

I don't know how to start that function in background. Maybe start function via cron will be solution, but I can't execute that function every second.

Comments

LaurentAjdnik’s picture

I think you should use cron indeed.

A single function would handle all the bids on all auctions for all users.

The very first lines should check whether there is something to be done.

If nothing's going on, return immediately without further actions.

jaypan’s picture

You can only run cron once every minute.

I didn't read any of your links, and I've only read what's posted in this thread. But you could set a script to run on every page load for every user by using hook_init(). This script could do whatever it is you want done. But it could be particularly resource intensive depending on what you are trying to do.

Contact me to contract me for D7 -> D10/11 migrations.

sakiland’s picture

Bid butler is like robot. It place bid instead of user when time to the end of auction is under 10s. So, that can happen more times within one minute. That's problem with cron.
Hook_init() can be a solution, but then I must have history log for all bids that happened from last user page load (and that can be many, many bids).

sakiland’s picture

OK. I will use script that will ran via cron every minute. If previous script is still running, than this script will exit.

Now, problem is how to make connection to database, because this script doesn't have any connection to the drupal. Do I must create connection to the database manually or I can include some file (like database.inc or bootstrap.inc, I don't know). I need functions: db_query() and db_fetch_array().

LaurentAjdnik’s picture

With your script in the drupal root, you can do a partial bootstrap of Drupal, up to the point when the DB functions are available:

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
sakiland’s picture

That's all I need. Thank you very much, it works :)

johsve339’s picture

Hi

Can you share your module?

sakiland’s picture

Yes, I will share. I must finish some things, but I think that it will be finish to 15th November.

neophyre’s picture

That would be perfect!

Rask’s picture

Is it done and will it work with Drupal 7?

sakiland’s picture

Within a few days I will finish "penny auction" module for Drupal 6. I didn't test with Drupal 7. I think that there is one or two function that will not work in Drupal 7. I'm not sure, I'll try to make Drupal 7 version as soon as possible.

Rask’s picture

Perfect. Hope to try out the module soon :-)

sjoerdsdrupal’s picture

I am looking forward to your module, I am searching for a good auction module that works with drupal

Wishing you the best and good luck,

kind regards,

Sjoerd

neophyre’s picture

any idea when this will be released? I'm keen to test this out...

sakiland’s picture

I hope this week. I'm working one project (that is my priority) and I hope that will be finish this week.

Rask’s picture

Any news?

droid19’s picture

Anyone looking for a drupal powered penny auction script please have a look with what I've done with http://biddini.com. Has a working bidbutler functionality as well.

Rask’s picture

Was your Penny auction module ever meant to happen?

sakiland’s picture

Yes, it will. But I'll first must adjust code like Drupal's standards. I can't publish code in this format. This is my first module that I plan to publish, so I don't have much experience.

marinex’s picture

Maybe drupal community would like to help you with format your code, I think here is a lot of people interested about your solution :-)

sakiland’s picture

Can I create a new cvs project, even if I hasn't completed all standards. I read http://drupal.org/node/100748, and I don't have documentation. I really want to commit code, but I need help about how to do that. Sorry, I don't have experience in this :(.

marinex’s picture

Hi, another nice script or solution base on drupal is auctionking

Rask’s picture

Auctionking - looks like Drupal, but what is underneath? Anyone know which auction module is used?

marinex’s picture

It is Drupal 5.19, 2009-07-01, ubercart-1-7... look at the source code of the page ;-)


another info http://www.drupalsites.net/weblink/auction-king


Marinex

Rask’s picture

Still no Penny auction module. Will it ever be released?

terry22’s picture

Hi, is your project still alive?
thank you for your answer.

prokopton’s picture

Is there a way to test this mod out?

summit’s picture

Hi,
auctionking is 404, biddini is 404. Why is this?

Is there somewhere a cents-auction drupal 7 (or drupal 6) module?
If not would somebody be willing to build it and preferrably integrated with commerce: http://drupal.org/project/commerce_auction

Thanks for your reply in advance!
Greetings, Martijn