RejectedSoftware Forums

Sign up

Vibe.d http server into dll

Good day.
Sorry for translate. English is not my native language.
I want to create a web interface for my non-D application.
I try to put "https://github.com/rejectedsoftware/vibe.d/tree/master/vibe.d/examples/diet" example into the dll.
After calling DllListenStart in main app i get Exception E0440001.
"Simple echo server" from http://vibed.org/docs works fine in dll.
Vibe.d can work within the dll. Or am I on the wrong way?

Exported function DllListenStart.

import vibe.appmain;
import vibe.http.server;
...
extern (Windows)
{
	void DllListenStart()
	{
		auto settings = new HTTPServerSettings;
		settings.port = 8888;
		settings.bindAddresses = ["::1", "127.0.0.1"];
		listenHTTP(settings, &handleRequest);
	}
}

package.json

...
"dependencies": {
	"vibe-d": "~master"
}
...

Thank you for help.

Re: Vibe.d http server into dll

On Mon, 11 Nov 2013 13:35:48 GMT, akaDemik wrote:

Good day.
Sorry for translate. English is not my native language.
I want to create a web interface for my non-D application.
I try to put "https://github.com/rejectedsoftware/vibe.d/tree/master/vibe.d/examples/diet" example into the dll.
After calling DllListenStart in main app i get Exception E0440001.
"Simple echo server" from http://vibed.org/docs works fine in dll.
Vibe.d can work within the dll. Or am I on the wrong way?

Exported function DllListenStart.

import vibe.appmain;
import vibe.http.server;
...
extern (Windows)
{
	void DllListenStart()
	{
		auto settings = new HTTPServerSettings;
		settings.port = 8888;
		settings.bindAddresses = ["::1", "127.0.0.1"];
		listenHTTP(settings, &handleRequest);
	}
}

package.json

...
"dependencies": {
	"vibe-d": "~master"
}
...

Thank you for help.

Did you call core.runtime.Runtime.initialize()/Runtime.terminate in DllMain? It's needed to set up the event driver and not doing this can result in an access violation (could be something else, too, though).

You'll also need to call vibe.core.core.runEventLoop somewhere to make the listenHTTP actually do something.

Re: Vibe.d http server into dll

On Tue, 12 Nov 2013 11:02:11 GMT, Sönke Ludwig wrote:

On Mon, 11 Nov 2013 13:35:48 GMT, akaDemik wrote:

Did you call core.runtime.Runtime.initialize()/Runtime.terminate in DllMain? It's needed to set up the event driver and not doing this can result in an access violation (could be something else, too, though).

You'll also need to call vibe.core.core.runEventLoop somewhere to make the listenHTTP actually do something.

Thank you very much for help.
My app do not have console (GUI only).
When i allocate additional console window i see "Listening for HTTP requests on 127.0.0.1:8888".
No more E0440001 Exception.
But no output on 127.0.0.1:8888.

vibe.core.core.runEventLoop + core.runtime.Runtime.initialize() make my "hello world" working.

But without console window i still have E0440001 Exception.
Is there any option that would disable registerLogger(ssstdoutLogger); in source\vibe\core\log.d:initializeLogModule().
Or how can i deregisterLogger( ss
stdoutLogger )?

P.S.
Vibe.d is great. Thanks.

Re: Vibe.d http server into dll

Anyway i can pipe stdout, stderr to null/file/etc...

Re: Vibe.d http server into dll

On Tue, 12 Nov 2013 13:25:03 GMT, akaDemik wrote:

On Tue, 12 Nov 2013 11:02:11 GMT, Sönke Ludwig wrote:

On Mon, 11 Nov 2013 13:35:48 GMT, akaDemik wrote:

Did you call core.runtime.Runtime.initialize()/Runtime.terminate in DllMain? It's needed to set up the event driver and not doing this can result in an access violation (could be something else, too, though).

You'll also need to call vibe.core.core.runEventLoop somewhere to make the listenHTTP actually do something.

Thank you very much for help.
My app do not have console (GUI only).
When i allocate additional console window i see "Listening for HTTP requests on 127.0.0.1:8888".
No more E0440001 Exception.
But no output on 127.0.0.1:8888.

vibe.core.core.runEventLoop + core.runtime.Runtime.initialize() make my "hello world" working.

But without console window i still have E0440001 Exception.
Is there any option that would disable registerLogger(ssstdoutLogger); in source\vibe\core\log.d:initializeLogModule().
Or how can i deregisterLogger( ss
stdoutLogger )?

I've added a runtime check using GetConsoleWindow (709e106). It's currently untested, but it should avoid now creating the ss_stdoutLogger in the first place.

P.S.
Vibe.d is great. Thanks.

Thanks!

Re: Vibe.d http server into dll

On Tue, 12 Nov 2013 13:55:46 GMT, Sönke Ludwig wrote:

On Tue, 12 Nov 2013 13:25:03 GMT, akaDemik wrote:

On Tue, 12 Nov 2013 11:02:11 GMT, Sönke Ludwig wrote:

On Mon, 11 Nov 2013 13:35:48 GMT, akaDemik wrote:

Did you call core.runtime.Runtime.initialize()/Runtime.terminate in DllMain? It's needed to set up the event driver and not doing this can result in an access violation (could be something else, too, though).

You'll also need to call vibe.core.core.runEventLoop somewhere to make the listenHTTP actually do something.

Thank you very much for help.
My app do not have console (GUI only).
When i allocate additional console window i see "Listening for HTTP requests on 127.0.0.1:8888".
No more E0440001 Exception.
But no output on 127.0.0.1:8888.

vibe.core.core.runEventLoop + core.runtime.Runtime.initialize() make my "hello world" working.

But without console window i still have E0440001 Exception.
Is there any option that would disable registerLogger(ssstdoutLogger); in source\vibe\core\log.d:initializeLogModule().
Or how can i deregisterLogger( ss
stdoutLogger )?

I've added a runtime check using GetConsoleWindow (709e106). It's currently untested, but it should avoid now creating the ss_stdoutLogger in the first place.

P.S.
Vibe.d is great. Thanks.

Thanks!

Maybe better check:

if (!GetStdHandle(STD_OUTPUT_HANDLE)) return;

Stdout pipe can work without ConsoleWindow.

Re: Vibe.d http server into dll

Am 13.11.2013 09:51, schrieb akaDemik:

On Tue, 12 Nov 2013 13:55:46 GMT, Sönke Ludwig wrote:

On Tue, 12 Nov 2013 13:25:03 GMT, akaDemik wrote:

On Tue, 12 Nov 2013 11:02:11 GMT, Sönke Ludwig wrote:

On Mon, 11 Nov 2013 13:35:48 GMT, akaDemik wrote:

Did you call core.runtime.Runtime.initialize()/Runtime.terminate in DllMain? It's needed to set up the event driver and not doing this can result in an access violation (could be something else, too, though).

You'll also need to call vibe.core.core.runEventLoop somewhere to make the listenHTTP actually do something.

Thank you very much for help.
My app do not have console (GUI only).
When i allocate additional console window i see "Listening for HTTP requests on 127.0.0.1:8888".
No more E0440001 Exception.
But no output on 127.0.0.1:8888.

vibe.core.core.runEventLoop + core.runtime.Runtime.initialize() make my "hello world" working.

But without console window i still have E0440001 Exception.
Is there any option that would disable registerLogger(ssstdoutLogger); in source\vibe\core\log.d:initializeLogModule().
Or how can i deregisterLogger( ss
stdoutLogger )?

I've added a runtime check using GetConsoleWindow (709e106). It's currently untested, but it should avoid now creating the ss_stdoutLogger in the first place.

P.S.
Vibe.d is great. Thanks.

Thanks!

if (!GetStdHandle(STD_OUTPUT_HANDLE)) return;

Stdout pipe can work without ConsoleWindow.

Good idea. Implemented:
9337ea0