Sydney
Sydney

Reputation: 503

Install4J: How do I restart multiple services after it has been updated in unattended mode without prompting the user for password

I use Install4J to install my application which is comprised of two services (two launchers) from a single JAR. I want to update my application in Unattended mode, then stop both services and start both services without having to ask the user to enter the administrator's password. Both services are initially started as root and I have verified using the 'ps' command that they are running as root when one of the services calls the ApplicationLauncher.launchApplication Install4J Integration API method.

My Install4J Updater is able to download the new version and stop the calling launcher, but the problem that I'm seeing is that I'm not able to stop the second (non-calling launcher) nor am I able to start the calling launcher.

This error is very strange because I've noticed that if I stop both services and then start both services using

sudo <ServiceLauncher1> stop
sudo <ServiceLauncher2> stop
sudo <ServiceLauncher1> start
sudo <ServiceLauncher2> start

..the whole thing works. It downloads the update, stops both services, then starts both services just fine. I've noticed (in OSX) that the launcher icon for the auto updater is also different (black terminal icon (does not work) vs white java icon (works).

I'd very much appreciate some help on this. Thanks!

Upvotes: 1

Views: 349

Answers (1)

Sydney
Sydney

Reputation: 503

In my case (two services), the Update installer runs as a child process of the service that launched it. Due to part of the update process requiring both services to be stopped and then started the problem is that stopping the calling service causes the whole update installer to be killed.

My solution is to have each service stop/start the other one by using two Update applications in Install4J.

Service #1 --> Updater #1:

  1. Check for new version
  2. Download new version
  3. Install new version
  4. Stop Service #2
  5. Start Service #2 (At this point, Service #2 is fully updated and running)
  6. Notify Service #2 to perform update on Service #1

Service #2 --> Updater #2:

  1. Stop Service #1
  2. Start Service #1 (At this point, Service #1 is fully updated and running)

Upvotes: 1

Related Questions