I'm using Windows containers and the microsoft/nanoserver as my base. I'm trying to start up a Tomcat server during the build, but when I do so the build hangs and all I can is cancel it. Unfortunately I have to start the server so it will deploy a war file so that I can then stop the server and alter its configuration. I know I can just run the image, make my changes, and then commit but this seems like cheating. The only thing I can think of is that the startup / catalina script is writing to stdout, but I've tried redirecting to null and it still hangs. Any ideas out there for me to try?
Dockerfile excerpt:
RUN powershell start-process -FilePath .\startup.bat -ArgumentList "/c" -NoNewWindow -RedirectStandardOutput Out-Null
It looks like you can't have a java process running on the image during the build; I was able to fix this by using Start-Sleep to wait for about a minute and then kill any java process running on the machine. The build proceeded after that.
Related
I have developed a Windows-worker service and I want to start it in a docker-based environment for automated testing. Therefore I built it with the following command:
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true
Additionally I have the following Dockerfile:
FROM mcr.microsoft.com/windows/servercore/insider:10.0.17763.107
COPY ["Install/", "C:/Service/Name/"]
RUN powershell New-Service -Name "Name" -BinaryPathName "C:\Service\Name\Name.exe"
When trying to start the service with Start-Service -Name "Name" the startup takes long and the service stays in the state Starting and then I get an 1053-error in the Eventlog (LogName=System).
Due to the fact, that the service did not start I made another one, that is mainly based on the template in Visual Studio, so it should only log a message to the eventlog. This service has the same behavior. When installing it on my local machine everything works fine.
Do you have any ideas why the service remains in the state Starting even though it does already the tasks of the Running-state?
I solved the problem now, because I found the following issue: https://github.com/dotnet/runtime/issues/50020
UseWindowsService() does not work in Docker, so I had to specify WindowsServiceLifetime:
services.AddSingleton<IHostLifetime, WindowsServiceLifetime>();
I have configured a GitLab Runner to run on one of my computers (the computer is Windows and uses Powershell to run yml script commands).
For my repo I have configured the yml file to copy the contents of the build into another directory, then have the runner run: Start-Process -FilePath "$PROJECTNAME.exe" -ArgumentList "$PROG_ARG_1" after changing into that directory.
However, the pipeline succeeds but the process that has been started (using "Start-Process" above) cannot be found on the computer anywhere (has not actually been started).
Am I doing something wrong?
EDIT: it is running just as a "Background Process" (needed to open control panel to verify it)
We have an old application which uses has it's executable (EXE) build on VB6 (Setup Bootstrap for Visual Basic Setup Toolkit ). We are trying to silently install the setup by and running it in a scheduled manner using task scheduler.
Command use : Start-Process -FilePath "D:\SETUPXXX.EXE" -Verb runAs -ArgumentList "/qn"
While running this stand alone from a power shell console or command line the setup executes and shows up on the screen , completes installation and goes off(without clicking anything). This installs is successfully.
But wherever we are trying to schedule this on a task scheduler it doesn't pop up anything and neither it installs the application.
We tried other ways "setupxxx.exe /sc:\setup.log" but the results are same it works when executed from command line and pops up the installation completes but fails to do the same when scheduled or run as a batch file.
Is there a way to stop the installer popup coming which might be stopping the instillation while running.
Refer :https://theether.net/kb/100165
We've got several servers running MAR's the lastest version 2.0.9145.0
I can run all backup's manually and its runs without problems. But when i try to run it from scehduled backups it shows in task scheduler that its run but gives this error code:2147942401
If i manually input the arguements into powershell it runs fine. However the task scheduler is not kicking in the backups.
I've altered the permissions to a domain admin, changed PS path to syswow64. So now i'm lost.
Has anyone had similar and any ideas on how to fix it or at least run the commands from a bat file instead?
at the moment jenkins build my project and at the end the artifact is deployed on a remote tomcat via jenkins deploy plugin.
the problem is that after several redeployments this process fails (sometimes tomcat hangs or (un)deployment fails). in all cases stopping tomcat and manually undeploying helps.
Is there a way to stop tomcat before building/deploying, delete the old war and appfolder, and restart tomcat before deploy plugin wants to deploy the artifact?
thx in advance
You could write a batch file that does all the things mentioned:
stop tomcat
delete war files
start tomcat again
Then you can add a new pre/post build task in job configuration as execute batch and simply point it to run your batch file.
Added:
You can use PsExec - http://technet.microsoft.com/en-us/sysinternals/bb897553 It allows you to run processes remotely. Put batch on remote machine and from local one using Jenkins run sth like this: PsExec.exe \xx.xx.x.x C:\MyScript.bat
one addition to accepted answer:
it is important to reroute the output and error output of PsExec call (took me 2 days of debugging). See http://jenkins.361315.n4.nabble.com/remotely-executing-commands-td3476417.html
it seems that if called from java (like jenkins/tomcat) or .net PsExec hangs or quits with error. so the call should look like:
c:\someBatchWithPsExec.bat >>log.txt>&1
or explicitly on every call:
PsExec.exe -u [domain\remoteuser] -p [password] /accepteula \remoteMachine net [stop|start] Tomcat7 >>log.txt>&1
i guess if jenkins runs with domain\user u don't have to mention it in command?! (just tried it but it didn't work - the net commands fail)