online-auction-java icon indicating copy to clipboard operation
online-auction-java copied to clipboard

Start and stop ES using runAll hooks

Open ignasi35 opened this issue 7 years ago • 11 comments

Using the new feature (https://github.com/lagom/lagom/issues/762) allowing start and stop code to be hooked to runAll, it'd be useful to take elasticsearch in online-auction as an example for the feature.

ignasi35 avatar May 23 '17 06:05 ignasi35

@ignasi35 As per I can understand from context what we will need to do is

  1. Check if ES of proper version is available to run. if not then download and install it.
  2. Check if ES is already running.
  3. If ES is not running then start the new instance.
  4. Clean instance if ant cleaning needed to be done.
  5. Stop ES when sbt is being terminated.

Please let me know which of these should exist in process and which are not needed. Also let me know if I missed something.

lakhina avatar May 24 '17 08:05 lakhina

I think the example in the PR is quite illustrative: https://github.com/lagom/lagom/pull/763/files#diff-69be132232784c54f9b1cdfc434186af

I would build from that:

  1. if the folder target/elasticsearch-5.0.2 doesn't exist, download and unzip there
  2. don't check if it's already running and just execute the start command. It will fail on start and the user will have to deal with that.
  3. if sbt clean is invoked, all target folder is removed so no need to add any code there.

Does that make sense?

ignasi35 avatar May 24 '17 09:05 ignasi35

@ignasi35 Where should we download ES so that it do not have to be re downloaded every time after sbt clean

lakhina avatar May 24 '17 09:05 lakhina

I think we can do that on a separate PR.

ignasi35 avatar May 24 '17 10:05 ignasi35

@ignasi35 With which version of lagom comes the lagomInfrastructureServices. I am not able to find it on lagom 1.3.4

lakhina avatar May 25 '17 11:05 lakhina

@ignasi35 I have made the following changes in my build.sbt

Where am I going wrong?

lakhina avatar May 25 '17 11:05 lakhina

Hi @lakhina the feature is only available in master which means you will only see it if you compile lagom locally and make your PR depend on 1.4.0-SNAPSHOT.

ignasi35 avatar May 25 '17 12:05 ignasi35

@ignasi35 So should I upgrade online-auction to 1.4.0-SNAPSHOT or I should wait for this feature to come in stable version?

lakhina avatar May 29 '17 10:05 lakhina

Realized just now that SNAPSHOT do not exist as remote lib so I guess we should wait for stable version to add this feature to online auction. What do you say?

lakhina avatar May 29 '17 10:05 lakhina

This will not be mergeable until 1.4.0 is out, but in the meantime you can clone lagom/lagom and use publishLocal in sbt to test your changes. ;-)

ignasi35 avatar May 29 '17 13:05 ignasi35

@ignasi35 okay thanks. I am on it

lakhina avatar May 29 '17 17:05 lakhina