[Mongrel] Mongrel as Windows service with normal privileges

Luis Lavena luislavena at gmail.com
Thu Jun 5 06:14:29 EDT 2008

On Thu, Jun 5, 2008 at 11:23 AM, Ingmar Stieger <ml at stiegerhs.de> wrote:
> I digged a bit through the source code, and I am under the impression that a
> normal user may not query the service control manager with
> PROCESS_QUERY_INFORMATION. Could this be the case ?

Look at the source code for 0.3.4 you will find that a process can be
opened for readonly functions and perform PROCESS_QUERY_INFORMATION
without problems.

That worked on 32 and 64 bits versions of many Windows Servers and XP,
so shoudl work in your scenario too, unless that specific user lack
the permission to "run and control services" which you will need to
check with your sysadmin for that configuration.

> _process_name does not return the name and _process_name_dyn_psapi fails as
> well. (tested with 0.3.1 and 0.3.3). It looks like OpenProcess can not be
> used in this manner...
> In a totally unrelated project [1] I solved what I think you are trying to
> do here differently:
> I just pass the parameter "-runservice" from SCM in order to determine if
> the application should run as service (called from SCM) or as a normal
> console application. Maybe this would be an easier approach for
> mongrel_service as well ?

Basically mongrel_service inherited code from other project named
ServiceFB, which is a framework we created for other purposes at the

It worked without issues on lot of scenarios, and it automatically
determine the running environment so you avoid the requirement to
"analyze" the command line.

> I would create a proof of concept, but unfortunately, I am not proficient
> with FreeBasic...

Actually, it's basic, there are not too many keywords to worry about
(ruby has more) and it's like C, I mean, you don't need to hack a lot
of stuff to go low level :-)

> Bye,
> Ingmar

Luis Lavena
Human beings, who are almost unique in having the ability to learn from
the experience of others, are also remarkable for their apparent
disinclination to do so.
Douglas Adams

More information about the Mongrel-users mailing list