How to run 2 (or more) Wildfly instances on the same machine?
Asked Answered
L

2

6

I want to simulate 2 servers by running 2 independent instances of Wildfly. This is useful when you don't want to deploy all WARs on the same instance and then only be able to shut them down and start them together.

I'm using Eclipse with the JBoss plugin where in the Servers view I want to have 2 Wildfly servers that I can stop and run separately and simultaneously. How do I do that?

Limousine answered 11/10, 2017 at 21:17 Comment(0)
L
17

It's possible to duplicate your Wildfly installation folder, but that takes up more space and you would need to update both for every change. Instead it's possible to share the root folder and just create 2 standalones:

  1. In the installation folder, create new standalone1 and standalone2 folders from the default (or use the default as one of them).
  2. In there, in the deployments folder you can choose whichever deployments you need.
  3. For the ports not to conflict, the configuration/standalone.xml of one of the standalones must be changed as shown here: change the number from 0 to something else like 200

    port-offset="${jboss.socket.binding.port-offset:200}
    
  4. Now go to Eclipse and in the Servers view create a new Server. Give it some suitable name and click next.

  5. Choose create new runtime on the bottom dropdown menu and click next.
  6. Give it a suitable runtime name and in the Server base directorychoose the standalone folder name you want, like standalone1 above.
  7. Then just deploy there whichever of the files you need for that particular instance.

Do the same for other instances with different offsets (in the above 1 instance will be at 8080 and the other at 8280).

Limousine answered 11/10, 2017 at 21:17 Comment(5)
I wonder, is this the best approach? I mean, for production enviroments. In case you have more thoughts on that I'd love read about it.Salangi
@vinyoliver I don't know if this is best for production. What alternatives are better?Limousine
I've ended up doing something pretty close to your answer for production. We have several apps each one running on its own instance of Wildfly and We also have a Nginx server working as reverse proxy. What I usually do is one app per server/instance but this project had this constraint that we had to use the same server for several appsSalangi
I may be losing something, but what sets the other instance to specifically 8280?Crispen
@TheStudent Step 3Limousine
L
2

after doing above Mark suggested method we have to run wildfly

in Windows

standalone.bat -Djboss.server.base.dir=D:/AppServer/wildfly-10.1.0.Final/standalone1

standalone.bat -Djboss.server.base.dir=D:/AppServer/wildfly-10.1.0.Final/standalone2

in Linux

./standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone1

./standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone2
Lantana answered 5/2, 2019 at 9:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.