Our installation process includes a Windows Service which is installed if our software is configured to be installed as a server (vs. a client installation). I added a service library to be able to manage the services, then in the files, I added handlers for BeforeInstall and AfterInstall events...
[Files]
Source: "MyService.exe"; DestDir: "{app}"; Check: IsServer; BeforeInstall: BeforeServiceInstall('MyServiceName', 'MyService.exe'); AfterInstall: AfterServiceInstall('MyServiceName', 'MyService.exe')
procedure BeforeServiceInstall(SvcName, FileName: String);
var
S: Longword;
begin
//If service is installed, it needs to be stopped
if ServiceExists(SvcName) then begin
S:= SimpleQueryService(SvcName);
if S <> SERVICE_STOPPED then begin
SimpleStopService(SvcName, True, True);
end;
end;
end;
procedure AfterServiceInstall(SvcName, FileName: String);
begin
//If service is not installed, it needs to be installed now
if not ServiceExists(SvcName) then begin
if SimpleCreateService(SvcName, 'My Service Name', ExpandConstant('{app}')+'\' + FileName, SERVICE_AUTO_START, '', '', False, True) then begin
//Service successfully installed
SimpleStartService(SvcName, True, True);
end else begin
//Service failed to install
end;
end;
end;
When installing the service for the first time (doesn't already exist and isn't currently running), the installation/starting of this service works just fine. However, when running this installer on an existing installation (upgrade), the installer stops when it recognizes that this service is running, and prompts to terminate the process (before it calls the BeforeServiceInstall() handler)...
How do I prevent this prompt from appearing for services? I'm avoiding having to require a restart and would still like this prompt to appear for all other files.
There is currently no direct way to exclude a file from checking if it's in use. You can disable this control globally (by setting CloseApplications directive value to no), which I wouldn't recommend. Or you can set a filter for files, which will be checked (in the CloseApplicationsFilter directive), which for you might require e.g. to list all the files except your service executable, which is hard to maintain.
You may also list all the files to be checked by specifying a filter which won't match any of your files and adding them from the RegisterExtraCloseApplicationsResources event method is the same as doing this from the mentioned directive.
What I would suggest is to stop your service from the PrepareToInstall event method. Its reference explicitly suggests this (emphasized by me):
You can use this event function to detect and install missing
prerequisites and/or to shutdown any application which is about to
be updated.
This event method is executed before all the file in use checks are performed and allows you to say that you need a system restart for cases when stopping of your service fails for some reason. If you wouldn't require restart, you may just return a string with some sensible message what happened to the user.
For your script it would just mean to move the code from your BeforeServiceInstall procedure to the PrepareToInstall event method and remove the BeforeInstall parameter from the entry.
Related
I am writing restful API with Yii, but I am getting an SQL error in create function. My purpose is to add new data to the news table, but it asks me for the author_id. How can I do it without crushing the default create method?
Solution 1. Run this below query on mysql/phpmyadmin and restart server
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
Solution 2.
Open the my.ini or my.cnf file for editing (the file you have depends on whether you are running Windows or Linux).
Find the following line:
sql_mode = "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Replace it with the line below:
If the line is not found, insert the line under the [mysqld] section (if there is no [mysqld] section, create it).
sql_mode= ""
Restart the MySQL service for the change to take effect.
If restarting is not a feasible option at the moment, you may log into the database server and execute the below command for the changes to take effect immediately. However, the change will be discarded the next time the MySQL service restarts unless the above process is performed.
set global sql_mode='';
I will install our software from a client machine, and I want to run a procedure CreateServiceCMD which stops/starts three services on the file server. Therefore on the file server runs a fourth service, which will wait for a CMD-File. The advantage is: No Administrator privileges are needed for the installation!
You have to know how it works (should work):
start setup from client machine
after selecting the paths, the procedure CreateServiceCMD(stop) will create the CMD file on the server, and my special service will stop the three other services
installing the files on the server
starting the application once with the parameter "UpdateAutoClose" (see below), so the application will be started, the database will be updated, the application closes automatically, and everything is ok, and setup is finished
but before finishing I have to call the procedure CreateServiceCMD(start) that my special service on the server starts the other three services again.
I tried everything but I can't find the right position for the CreateServiceCMD(start). AfterInstall, PostInstall, wpFinished, DeInitializeSetup() and I tried it for hours...
[Run]
Filename: "{code:GetInstallDir|Program}\{#AppStartName}"; Parameters: "-UpdateAutoClose"; \
Flags: postinstall skipifsilent; \
Description: "{cm:LaunchProgram, {#AppName} {#AppVerTxt} Datenbank Update}"
The problem is, I have to wait till the application has closed again and then run my procedure, but I can't find the right place. Everything I tried is much too early.
Hope someone can help...?
I believe you are looking for the CurStepChanged:
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
{ installation is starting }
CreateServiceCMD(stop);
end
else
if CurStep = ssPostInstall then
begin
{ installation has finished }
CreateServiceCMD(start);
end;
end;
Im new to chef and trying to understand why this code does not return any error while if i do the same with 'start' i will get an error for such service does not exist.
service 'non-existing-service' do
action :stop
end
# chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* service[non-existing-service] action stop (up to date)
Don't know which plattform you are running on if you are running on Windows it should at least log
Chef::Log.debug "#{#new_resource} does not exist - nothing to do"
given that you have debug as log level.
You could argue this is the wrong behaviour, but if the service dose not exist it for sure isen't running.
Source code
https://github.com/chef/chef/blob/master/lib/chef/provider/service/windows.rb#L147
If you are getting one of the variants of the init.d provider, they default to getting the current status of a service by grepping the process table. Because Chef does its own idempotence checks internally before calling the provider's stop method, it would see there is no such process in the table and assume it was already stopped.
We have upgraded windows from 8.1 to 10.
Now in Windows 10 services installed by us are not running.
The same services are running properly if we install these services on Windows 8.1.
ON windows 10, we tried below things which didn't solve the problem.
services-> select service -> properties -> Set [Log on] as LOCAL SERVICE
Set full permission to "perticuler" user or "everyone" user for the folder where service files exist.
Change owner of folder as "everyone", "system" or "perticuler" user where service files exist.
Below is a workaround which works but not feasible for us since it requires password and actually we want to know the actual reason behind this problem.
workaround :
1. services-> select service -> properties -> Set [Log on] as "This account" where user can be selected and it also requires password. Refer attached image.
Please note that the service is a dot net(c#) service and it runs internally a jar file. if it is able to run jar file then only service starts successfully.
Thanks in advance
I have found the cause and solution.
[Cause of problem]
Service unable to understand that, to run JAR file, which program should be run.
[Detail]
I tried to debug the code.
At the location where process is started, popup message like shown in below image is occurred.
location : processSample.Start()
It means that atleast once user need to select the program.
If we select [Java(TM) Platform SE binary] once, then after that the
service always runs successfully.
This behavior is in Windows 10 only.
In addition to program selection, user setting shown in image in question is also required to run the service.
I want to say that, in default program setting already correct program is selected for .jar files as shown in below image, but still windows 10 asks user to select program once.
[Solution]
Run JAR file from windows(c#) service with settings below :
sampleProcess.StartInfo.FileName = "javaw.exe";
sampleProcess.StartInfo.Arguments = "-jar Sample.jar";
sampleProcess.StartInfo.WorkingDirectory = #"C:\SampleFolder";
sampleProcess.StartInfo.UseShellExecute = false;
sampleProcess.EnableRaisingEvents = true;
sampleProcess.StartInfo.CreateNoWindow = false;
Here working directory is the location where the [Sample.jar] does exist.
additinally a Path environment variable must be set in order to execure "javaw.exe".
Before fix I had implementation as below which is not proper for every system environment :
sampleProcess.StartInfo.FileName = "Sample.jar";
sampleProcess.StartInfo.WorkingDirectory = #"C:\SampleFolder";
sampleProcess.EnableRaisingEvents = true;
sampleProcess.StartInfo.CreateNoWindow = false;
clear case trigger implemented and working in server but while trying in client it's throwing below error - this trigger prevent from unreserved checkout
error checking out
M:\view_main\xxx\abcd.java
can't execute "C:\Program FIles\IBM\RatinalSDLC\Clearcase\bin\ccperl //\trigger\trig_reservedonly.pl";
the system cannot fine the specified file
Trigger action "-exec "C:\Program FIles\IBM\RatinalSDLC\Clearcase\bin\ccperl //\trigger\trig_reservedonly.pl"
unable to run : Exec format error
unable to check out "M:\view_main\xxx\abcd.java"
A trigger script must be accessible by all clients.
It is best to declared it in an UNC path (a shared path \\server\folder\path\to\script).
That way, the script is accessible from any client able to access and read the content of that shared path.
See for instance an example at "Creating a ClearCase trigger to disallow checkins for certain Rose RealTime versions".
I also used that technique in "how to get a notification for every checkin in clearcase for a particular Vob".