I've been using http://commons.apache.org/proper/commons-daemon/ to create a windows service for the Wildfly startup (using exe mode as proposed in some blogs). The problem is, that the service is immediately marked as running. I have some other services that are only allowed to start once Wildfly is up and running. Making these services depend on the Wildfly service won't work, because the startup takes between 20-60 sec.
Is there a way to make procrun wait for a return value or at least for a fixed time, before the service is marked as running?
I don't use that service wrapper but the one that ships with wildfly (in the docs\contrib\scripts\service folder. (See http://www.mastertheboss.com/jboss-server/jboss-configuration/run-jboss-as-service-howto for details).
But I suspect the problem is one I see as well. wildfly starting is a quick process process - 1 or 2 seconds - but what then takes the time is deploying your ear or war files so it can actually do something useful. You can tell when that's happened by the
myEar.ear.deployed file turning up. With the wildfly service wrapper, everything is done in the service.bat script, and starting the wildfly service basically means running the code at the :commandStart label.
:cmdStart
if /I "%~1"=="/name" (
if not "%~2"=="" (
set SHORTNAME="%~2"
)
)
%PRUNSRV% start %SHORTNAME%
echo Service %SHORTNAME% starting...
goto cmdEnd
after the echo of Service starting, you could put in a sleep for 30 s
timeout /t 30 /nobreak
or you could try looking for the .deployed file and looping until its there or a .failed file is there. (A simple timeout is easier!)
Related
Suddenly Websphere server is automatically started.
I stop many times but started again automatically.
Even I removed project from the web sphere and removed websphere from the project and Again add for the same.. But still I it is starting.
I also run the below command,
Server stop server_name
below Message is showing
Stopping server server_name
So it is not stoping. How to stop forcefully? or Kill existing process?
Your question doesn't state what OS you're running on, but Liberty doesn't currently ship with any means to automatically start the server (like a Windows service), so when you say "started again automatically", it is more likely that the server is never shutdown. Liberty runs as a process that can be killed and the process id can be determined by looking at the messages.log file in the server logs directory. The preamble of the file will contain a line like this:
process = 11488#YourHostName
Depending on the OS you're running on, you can use the kill command (Linux or MacOS), or the Windows Task manager to end the process. When you restart the server, you may want to specify the --clean option like this:
server start defaultServer --clean
I am using Wildfly 9 under both Ubuntu an Windows servers. Sometimes, I need to restart the servers but after I stop the server, I cannot start it again. There is a red message box saying Server start failed. The detailed message is:
WFLYCTL0158: Operation handler failed: java.lang.IllegalStateException
I cannot stop Wildfly because there is a bug on Windows preventing the user from stopping Wildfly server through Services. The process stucks at Stopping but it never stops the Wildfly service. I have to restart Windows itself to make it work again.
Anyone facing this problem? How can I overcome this?
Here is how I got around the "stopping" issue.
To kill the windows service without having to reboot windows, create a batch file call it killwindowsservice.bat or whatever. Put the following in it.
set SERVICE=%1
echo Killing Service %SERVICE%
FOR /F "tokens=3" %%A IN ('sc queryex %SERVICE% ^| findstr PID') DO (SET pid=%%A)
IF "!pid!" NEQ "0" (
taskkill /f /t /pid !pid!
)
Just call your script with the name of the windows service. So for me I call my Windows Services the name of my application server instance. So for eaxmple "Server01".
So for me I would call it like:
killwindowsservice.bat Server01
And the script will kill the windows service.
The Windows service scripts that come with Wildfly 8.x+ DO NOT work on Windows 2012/2012 R2. I have not gotten them to work. I went and grabbed the jbosssvc.exe from a previous version of JBoss and customized the Windows Service scripts that come with it. And they work perfectly. I'm using these scripts on 12 Wildfly servers now without a problem.
This is how I manage Wildfly on Windows:
Open Task Manager
Eanble Command Line column under Details tab
Find Wildfly process (the path will tell you correct instance)
Kill the process
Then the server starts through admin console. You can also kill Wildfly master process and start over.
I am new to WildFly and I am trying to know more on deployment scanner process.
There are two deployment mode in WildFly auto deploy mode and manual.
If I restart WildFly, my ear files are deploying again. As per WildFly forum it should deploy again if there is a change in file(based on time-stamp).
I am running my WildFly in standalone mode.
When I run the following command:
sh standalone.sh -b 0.0.0.0
and its started within 2 minutes. Again if I restart server is taking same time.
It is re-deployed using timestamp only in a running instance. An application needs to be deployed to 'run' thus when the servcer starts it deploys the applications and stops aka undeploys them when it stops.
Whenever you deploy anything on wildfly manually ( I mean using admin console ) , it put a entry in standalone.xml ( or other xml if you configure to use them ). You will find an entry referring to it. With this during next restart it knows what to re-deploy.
In scanner mode , it know location of scanner directory and during startup , it picks content from it.
Now for >>>>> As per WildFly forum it should deploy again if there is a change in file(based on time-stamp).
Ans : If autodeployed is true ; then while server is running and you update any file , it will be picked up and wildfly will re-deploy app.
Hope this helps
I have a critical windows service that I need for my web application.
Unfortunately, the windows service does not start properly, but remains in a status of "Starting" for about 7 minutes and 38 seconds, and then fails.
My web application works fine when the service is in the "Starting" mode.
I have a windows scheduled task that runs every minute to restart the service if necessary.
net start "my service"
Therefore there is a gap of about 22 seconds from when the service fails until it starts up again. In additional it takes an additional 30 seconds or so for my application (which is dependent on this service) to start working.
I have intentionally not named the errant service. I did open a separate question https://stackoverflow.com/questions/8470975/oracle-oc4j-service-keeps-stopping whose aim was to actually solve the problem.
In this question, I am not trying to solve the problem, but rather find a workaround to try and keep this service in a status of "Starting" the whole time.
What is infuriating, is that until I restarted the server today, my workaround of restarting the service every 3 minutes actually worked, with no application downtime whatsoever.
Does anybody have any suggestions? I did try changing the registry key of ServicesPipeTimeout to 86400000 (24 hours!) in a bid to keep the service in the status of "Starting" for longer.
I have found a possible solution to my problem that I am very uneasy about...
I downloaded WinDbg from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8279
I opened WinDbg and did Attach to Process, and selected my service.
As long as WinDbg is open, it seems to "hold" the process and prevent it from stopping.
How long it will continue to do so, remains to be seen, but it has held for over half an hour now (whereas before the service stopped after 8 minutes)
If you have the timeout set to 24 hours and the service does not start or stay in 'starting' mode , then it must be either crashing or closing itself down.
If you want to try to restarting your service immediately it crashes, then, on the properties of your service, select the 'Recovery' tab. You should be able to set the service to restart on first, second and subsequent failures and set the service to restart after 0 minutes,
Note, this will not work if windows thinks that the service is closing down properly.
It should go without saying that this is a last resort only if you can't get whoever wrote the service to fix the problems.
Try specifying 'Restart the Service' for all three sections on the Recovery tab, but that will only work if the service is ending abnormally.
Our company faced a similar problem and we developed Service Protector, a commercial application that can babysit a service and keep it running 24/7. It may work in your situation too.
I am running the Tomcat that gets delivered with your Eclipse download (no, I don't want to download and install the entire Tomcat), and sometimes it hangs when stopping or restarting, and the only way I can find to make it work is restarting all my Eclipse. I am using it under Windows.
Is there any way to kill the Tomcat process (which doesn't appear in the Task Manager)?
It appears as javaw.exe in task manager. An alternative is to execute Tomcat/bin/shutdown.bat.
As to the hang problem, are you sure that your webapp isn't spawning unmanaged threads which might be blocking Tomcat's shutdown?
On Windows, if you know the port Tomcat listens to (below, it is 8080), you can find the PID of the Tomcat process and then kill it from cmd:
> netstat -aon | find "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 2196
TCP [::]:8080 [::]:0 LISTENING 2196
> taskkill /pid 2196 /f
SUCCESS: The process with PID 2196 has been terminated.
I use better way to shutdown tomcat when it is not found in task manager.
1) Download TCPView(only 285kb) from following link.
http://technet.microsoft.com/en-in/sysinternals/bb897437.aspx
2) Extract folder and start TCPView application.
3) Right click on java.exe and select End Process option.
this would stop your tomcat easily.. This tool is very useful in monitoring port usage.
NOTE: Running TOMCATPATH/bin/shutdown.bat may not shutdown Tomcat when it contains some demon or unmanaged
threads. In such cases TCPView works fine without any issues.
You can set a timeout on startup and shutdown for your Tomcat server in Eclipse. If these timeouts are exceeded, Eclipse will pop up a message asking you if you want to kill it, or keep waiting.
To set these, double-click the name of the server in your Servers tab. It'll open a window like this:
There's a Timeouts section on the right hand side. I set startup to a day (so I can debug startup without it timing out), and shutdown to 30 seconds to be generous (usually this can be very short, since most apps can survive a forced shutdown with no issues).
If you use Linux, try the following steps.
List Tomcat processes (e.g., ps aux | grep catalina)
Locate the strings that look like this: myname 2244 5.5 0.3 57020937 2110741 ? Sl Oct03 5160:01 /usr/lib/jvm/java-1.8.0-<...>/bin/java <...> org.apache.catalina.startup.Bootstrap start
Copy-paste everything between /usr/lib/jvm/<...> and <...>.Bootstrap
Add stop at the end of your command and run it
Essentially, you would take the very same command that was used by Eclipse to start Tomcat and modify the last argument to stop Tomcat.