• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Executing simple one-time tasks using EOF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Executing simple one-time tasks using EOF


  • Subject: Re: Executing simple one-time tasks using EOF
  • From: Miguel Arroz <email@hidden>
  • Date: Sat, 28 Jun 2014 16:19:06 -0700

Hi,

  There are two main differences (at least):

  1) Migrations gives you the guarantee that the code is run only once in your app cluster. didFinishLaunching runs every time an instance starts, on all instances. So you need to write code to make sure that only one instance runs the code, and only once. Migrations give you that for free.

  2) You need to remove or disable the code in didFinish after you don't need it anymore. In migrations, you don't, you can leave the code there for future reference, because it will never run again.

  Regards,

Miguel Arroz

On Jun 28, 2014, at 15:56, Hugi Thordarson <email@hidden> wrote:

How is that different from just running tasks from e.g. Application.didFinishLaunching()? Can you run migrations without starting your entire application?

- hugi


On 28.6.2014, at 22:51, Paul Hoadley <email@hidden> wrote:

On 29 Jun 2014, at 8:04 am, Miguel Arroz <email@hidden> wrote:

 Can't you use Wonder migrations? I have the vague recollection I did that on a past life for doing tasks like that. AFAIK there were two methods you could define on a migration, the first before EOF loaded the models, and the second one after. But I don't touch that for quite some time now, so I may be confused.

Yeah, I’ve certainly been known to do some one-time EOF-related tasks in a migration class—you can leave upgrade() and downgrade() empty, make sure you implement IERXPostMigration, and run the code in postUpgrade().  As for how dirty that makes you feel, I guess it’s a case-by-case basis.  I’ve justified it from time to time because the postUpgrade() one-time tasks were model-related, and didn’t feel like a terrible abuse of migrations.  YMMV



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Executing simple one-time tasks using EOF (From: Hugi Thordarson <email@hidden>)
 >Re: Executing simple one-time tasks using EOF (From: Miguel Arroz <email@hidden>)
 >Re: Executing simple one-time tasks using EOF (From: Paul Hoadley <email@hidden>)
 >Re: Executing simple one-time tasks using EOF (From: Hugi Thordarson <email@hidden>)

  • Prev by Date: Re: Executing simple one-time tasks using EOF
  • Next by Date: Re: Executing simple one-time tasks using EOF
  • Previous by thread: Re: Executing simple one-time tasks using EOF
  • Next by thread: Re: Executing simple one-time tasks using EOF
  • Index(es):
    • Date
    • Thread