Rollback Service installation in unattended mode with install4j - install4j

I'm trying to create an Install4j updater in unattended mode using Stand Alone Update Downloader and invoke it using the api. (this is working)
The application is a Windows Service and it opens http ports.
I would like to be able to rollback to the previous installed service if the new installed version isn't working. There should be no user interaction to do it.
What I was planning to do is:
Install the service
Start the service
Call Wait for Http Server Action that calls an Url of the service to check if my new updated service is working as intended.
If it doesn't returns a 2xx it will initiate the rollback process
But what I'm seeing is that the rollback process starts but it stops and uninstalls the new service but the previous service is never reinstalled.
What I would want it to do when rollbacking is:
Stop the new service
Uninstall it
Rollback any other files added by the new version
Reinstall the previous service
Start the previous service
Is there any way to achieve it ?
Edit:
I have those actions in the installer:

In this version of Install4j (10.0.4) the rollback mechanism doesn't handle this scenario. As specified by the comment of Ingo Kegel this will be improved in further version.
What is working with this version is that:
Add the condition on Install service to not to run it when updating like this: !context.isUpdateInstallation(). There will no rollback of the service when updating.
To keep the service started, we added a Stop a Service at the beginning. This way if there's a rollback, the Stop a Service will be rollbacked, so it will restart the service.

Related

ServiceFabric not closing CommunicationListener on update?

We have some custom implementation ICommunicationListener and in our tests we find out that during application update the CloseAsync method of the listener is not invoked. In VS when we close app it is invoked. This is important for us because we are suspecting that it cussing our troubles during update of the application – it sometimes fails so we have to write a script that delete service and type from cluster and then installation is not failing. Rolling back on failed installation was always on node where service with ICommunicationListener existed.
Is this a know problem? How to force closing on update?

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!
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:
Check for new version
Download new version
Install new version
Stop Service #2
Start Service #2 (At this point, Service #2 is fully updated and running)
Notify Service #2 to perform update on Service #1
Service #2 --> Updater #2:
Stop Service #1
Start Service #1 (At this point, Service #1 is fully updated and running)

Wix Uninstall service issue

So basically what I'm trying to do is to have a number of additional parameters (namely SERVICENAME and SERVICEDISPLAYNAME) in the installer of my application (which runs a service) instead of hard-coding them in the installer. The installation runs fine with this change. However the problem I have is when I run a silent uninstall. It appears that the Service Control does not stop the service before removing it from the machine and I get a dialog box telling me that the service is still running and asking me if I want the service to be stopped before uninstalling it. What should I do to make it work (i.e. make the service control to stop the service automatically before removing it)?
The ServiceControl Element is just an abstraction for the underlying ServiceControl Table. Neither "do" anything. Instead, they merely express what needs to be done. The stopping of services is performed by the StopServices Action which gets it's orders from the aforementioned table.
In Windows Installer, properties are not persisted automatically after an installation is complete. If you log the installer you will likely find that your SERVICENAME property is null and the StopServices action doesn't know what to do with that.
Take a look at the following:
The WiX toolset's "Remember Property" pattern
If you implement this pattern, the data for SERVICENAME should be restored during the uninstall and the

Installshield not stopping service during minor upgrade

In my installer I have a component that installs an NT service. I have a problem that during minor upgrade the service is not stopped. I observed the log generate by installshield during upgrade and it reports it is doing the action StopServices and its return code is 1. I have also started process hacker to log for services start/stop events but the service is never stopped during upgrade. I have also verified that during uninstall the service in stopped and then removed. Any idea why this is happening?
I am using installshield 2008, but any installshield related answer will be really helpful.
Eventually I was not able to overcome this issue. Spent several days trying to figure out what exactly is going on and was not able to figure out why the service is neither stopped nor started during minor upgrade. I was forced to write custom actions that perform this operations and used sc.exe for them. This is not the first unsolvable issue in installshield that I was forced to fix with a custom action. Hope this answer will save several days to someone.
It can be done by install script and a custom action that executes it.
An example for stopping/starting a service (i used it in IS2016):
#include "ifx.h"
//Function to stop the service
export prototype stopService(HWND);
function stopService(hMSI)
begin
ServiceStopService ( "my service name" );
end;
//Function to start the service
export prototype startService(HWND);
function startService(hMSI)
begin
ServiceStartService ( "my service name" ,"");
end;
In order to run the custom action during minor upgrade only, set its condition to:
REINSTALLMODE=vomus

Stopping the service and the babysited application before uninstalling

I have a service MyService.exe that is babysitting my application MyApp.exe, meaning it starts the application when this one crashes or whatever. Basically when the service is stopped the application is stopped (by the service) and when the service is started the application is started by the service.
In order to stop my service and by that my application when uninstalling I'm doing:
<ServiceControl Id='MyServiceControl' Name='MyServiceForTest' Start='install' Stop='uninstall' Remove='uninstall'/>
But when I want to uninstall everything I get the error message: "The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.". If I manually stop the service before running the uninstaller I don't get this msg as both my service and my application aren't then running anymore.
In the log file I noticed that this happens in InstallValidate and I get this message b/c of MyApp.exe being running.
I think what happens is: the uninstallers checks the running applications, it notices that the MyService.exe and MyApp.exe are both running, detects probably that the MyService.exe will be stopped by the uninstaller itself as instructed, but doesn't know about the MyApp.exe that this one will also be terminated once the service will be stopped so it will show the reboot-message.
I can't just close MyApp.exe from uninstaller b/c the service will restart it again.
How could I solve this problem so that the user won't need to reboot or to manually stop the service before doing an uninstall/upgrade? Also, I can't change MyService and MyApp code anymore so I will have to do this from the (un)installer only.
TIA,
Viv
I would expose a mechanism in your service in which your installer can instruct it to stand down and terminate the application. This way when Windows Installer costing looks for locked files it doesn't find any.