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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
szczecinAuthor Commented:
thanks, it looks like a solution.

I also will give a try to
szczecinAuthor Commented:
good one
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Server OS

From novice to tech pro — start learning today.