On Mon, 2010-03-29 at 15:49 -0500, Kerry Bonin wrote:
> I’ve extended qpidd to run as a self-installing windows service and am
> working on cleaning up my code before submitting a patch.
>
>
>
> I have one ugly issue remaining I’d like to ask for help with, as it
> intersects both boost issues and qpidd code style, and I’m not at all clear
> what the ‘best’ way to proceed would be within those contexts.
>
>
>
> Specifically, I need to capture the original argument list passed into qpidd
> so it may be preserved for when the application runs as a service. I’ve
> currently added a small block of #ifdef WIN32 code to the top of the main
> function in qpidd.cpp that prescans the arg list, and on an install arg hit
> passes the full arg list (arfc,argv) to a function that installs the
> service, then exists.
Windows, unlike Unix has a system call which exposes the cmdline:
LPSTR WINAPI GetCommandLine(). So you can always get the command line
from any part of the executable without having to pass it down there.
However this does only return the single command line string without any
parsing or splitting so you need to do that yourself.
However having said that, in the case of a windows service, I'd not
expect anything important on the command line in any case. I'd expect
configuration to come from the qpidd.ini config file or perhaps from the
registry. I don't know whether the boost program options library can do
registry also, but if not I guess it would be some additional work for
someone.
Andrew
>
>
>
> I’d like to move this into the platform specific QpiddBroker.cpp file (as I
> understand the #ifdef {platform} violates a qpid style rule), but 1) I don’t
> see the arg list being preserved past boost program_options parse(), and 2)
> I believe I need the arg list BEFORE boost gets ahold of it, as boost
> automagically folds config file & environment arguments into the options –
> nice for runtime use, bad for deferred execution like my use case (install
> now, run later.)
>
>
> Suggestions?
>
>
> Also, FWIW:
>
>
>
> Features now working (currently testing WinXP SP2 > Win7, Server 2008, all
> 32 & 64 bit)
>
> --install (install this executable as a windows service)
>
> --start (start the service)
>
> --stop (stop the service, including any dependant services)
>
> --uninstall (uninstall the service)
I had an idea that having install/uninstall as service options was
nowadays considered extremely poor security practice and should be
entirely left to an installer. But I may have misremembered that.
>
>
>
> Features in progress: (names are bad, need better...)
>
> --account {name} {password} (default=LocalSystem)
>
> --startup auto|manual
The above comment would go along with these options too. I don't think
they have a place inside the executable itself. But perhaps someone with
real Windows security credentials can shed some light here.
>
> Use of event log
I assume this is is integrated into the internal Logger, or is it a
separate development. If it is in the Logger, how do you generate the
message catalog?
Andrew
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]