• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2454
  • Last Modified:

Launching service with processor affinity


I am trying to run my jboss as services with predefined processor affinities. After trying imagecfg.exe (which somehow not works for java.exe file) and others, I have decided to modify run.bat script, which basically runs org.jboss.Main classe, I did it as follows:

start /affinity 3 %JAVA% "%JAVA_OPTS%" ^
   -Djava.endorsed.dirs="%JBOSS_ENDORSED_DIRS%" ^
   -classpath "%JBOSS_CLASSPATH%" ^
   org.jboss.Main %*

Open in new window

It works perfectly with one BUT. I start this as Windows Service. When I click "START" it gives me error that service started and stopped, but I see in task manager that it actually works! Just the service state is incorrect (stopped). I think it is because during service start, it takes output/result of "start" program, not "java.exe" which is being launched by "start" command.

Is there any way to tell service manager it's running? I mean, like return some result code or redirect java.exe output? To clarify, if I remove

start /affinity 3

Open in new window

then I have original fully working script, but then jboss uses all CPU instances, what I'd like to avoid.
  • 2
2 Solutions
See this page here, this excerpt here might do the trick (modify according to your needs) :

If you’re trying to control a service, you could use instsrv/srvany to create a service that wraps the start or psexec command around the real service binary. For example, the commands below create another version of the spooler service that will only run on the first processor.

instsrv Test c:\util\srvany.exe
reg add hklm\system\currentcontrolset\services\test\Parameters
reg add hklm\system\currentcontrolset\services\test\Parameters /v Application /t reg_sz /d cmd.exe
reg add hklm\system\currentcontrolset\services\test\Parameters /v AppParameters /t reg_sz /d "/c start /affinity 1 C:\WINDOWS\system32\spoolsv.exe"
szczecinAuthor Commented:
thanks, it looks like a solution.

I also will give a try to http://affinitychanger.sourceforge.net/
szczecinAuthor Commented:
good one
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now