logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: change apache service priority (transparently)
Author
shixy



Joined: 17 Mar 2007
Posts: 1

PostPosted: Sat 17 Mar '07 23:39    Post subject: change apache service priority (transparently) Reply with quote

Short description: When using apache as a service on Windows, there are actually 2 "apache.exe" processes running. When apache does something, only one of them (second) uses the CPU.
Using WinAPI I must change its priority. I can find a PID by service name and change its priority, but only 1 of 2 "apache.exe" processes is changed, the first one. How can I get the second apache.exe PID to change its priority too?


Full description:
First of all I'll describe the situation.

I develop a windows program, which uses apache & php (asks for some actions via http). It may look strange, but I found apache is very suitable for my targets.

But how can other user use my program without installing and configuring apache & all that stuff?
For this I have created an installer, written in C++. The installer acts like a regular installShield program (shows "welcome", asks where to install and install the program files there), but in the end it also transparently extracts Apache with php to some certain folder, writes httpd.ini with needed document root and listening port (port differs from 80, so it will not conflict with possible other 80port program like IIS).
Then, using WinAPI I install apache as service with unique name (for example "MyCoolApache") and start the service.
I also have uninstaller, which stops the service and uninstalls it. Everything is transparent, so user will never even guess his computer has a running apache Smile
OK, it works perfectly, but...
For some reasons I need to tweak apache's priority, because when it is higher than normal - the whole process works much faster for my program.
First of all let's look at the Task Manager.
I have 1 apache service running, but Task Manager shows TWO processes with the same name: "apache.exe". When I load the hard php script, I see only one of them (second one) eats CPU time.

OK, I changed it manually in task manager, now I have to do the same in my program (to make it transparent like all other things I've done).
I try to do it using the same winAPI. I get the PID of a service process named "MyCoolApache" and change the process priority.

Look at Task Manager... Yes! The priprity is changed, but... only the first "apache.exe" process, the second one has Normal priority!..

Does anybody know how and where I can get the PID of the second apache.exe process? Listing all the processes and finding all apaches is wrong, because there may be other processes with the same name (maybe the user is web developer and has his own apache service - I cannot touch it).
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Sun 18 Mar '07 12:20    Post subject: Reply with quote

Not to hard to do.

First off you might want to compile the modules you use - php statically to cut down on dll's you need.

then rename apache.exe or httpd.exe to MyCoolApache.exe

and execute that via MyCoolApache.exe -X (capital x)

Once your done just trance MyCoolApache.exe and kill it. (there is only one with the -X parameter)
Back to top


Reply to topic   Topic: change apache service priority (transparently) View previous topic :: View next topic
Post new topic   Forum Index -> Apache