Re: Integrate vibe.d into Windows Service
On Wednesday, 21 November 2018 at 09:59:19 UTC, Andre Pany wrote: Hi, I translated the CPP example of a windows service to D. https://docs.microsoft.com/en-us/windows/desktop/Services/svc-cpp [...] Today I needed this too, and after some searching I came across this package which works ok for me with vibed: https://code.dlang.org/packages/daemonize
Re: Integrate vibe.d into Windows Service
On Friday, 23 November 2018 at 21:35:57 UTC, Andre Pany wrote: On Friday, 23 November 2018 at 21:27:26 UTC, Kagamin wrote: You don't need to initialize runtime because it's initialized by standard D startup code, but you need to attach threads that are not created by D or static constructors won't be run and only C-level code would work there. Thank you, I wasn't aware of this. For references, I found this post which explains thread_attachThis. I assume you meant this function. Kind regards Andre Post explaining thread_attachThis https://forum.dlang.org/thread/ounui4$171a$1...@digitalmars.com
Re: Integrate vibe.d into Windows Service
On Friday, 23 November 2018 at 21:27:26 UTC, Kagamin wrote: You don't need to initialize runtime because it's initialized by standard D startup code, but you need to attach threads that are not created by D or static constructors won't be run and only C-level code would work there. Thank you, I wasn't aware of this. For references, I found this post which explains thread_attachThis. I assume you meant this function. Kind regards Andre
Re: Integrate vibe.d into Windows Service
You don't need to initialize runtime because it's initialized by standard D startup code, but you need to attach threads that are not created by D or static constructors won't be run and only C-level code would work there.
Re: Integrate vibe.d into Windows Service
On Wednesday, 21 November 2018 at 15:05:31 UTC, Kagamin wrote: Start vibe in another thread and return from ServiceMain, see https://docs.microsoft.com/en-us/windows/desktop/Services/service-servicemain-function also ideally you should report running state only after vibe initialized, opened sockets and started listening, before that it's not really running. I tried to wrap WaitForSingleObject into a Fiber by using command runTask. In theory it should work fine but the service (app) just crash without any information on an empty runTask function. Also calling listenHTTP crashes the service. Here I am able to catch the Error "eventcore.core static constructor didn't run!?". I created a github issue with complete source code here https://github.com/vibe-d/vibe-core/issues/105 Kind regards Andre
Re: Integrate vibe.d into Windows Service
On Wednesday, 21 November 2018 at 15:05:31 UTC, Kagamin wrote: Start vibe in another thread and return from ServiceMain, see https://docs.microsoft.com/en-us/windows/desktop/Services/service-servicemain-function also ideally you should report running state only after vibe initialized, opened sockets and started listening, before that it's not really running. Thanks a lot. I will try. Kind regards Andre
Re: Integrate vibe.d into Windows Service
Start vibe in another thread and return from ServiceMain, see https://docs.microsoft.com/en-us/windows/desktop/Services/service-servicemain-function also ideally you should report running state only after vibe initialized, opened sockets and started listening, before that it's not really running.
Integrate vibe.d into Windows Service
Hi, I translated the CPP example of a windows service to D. https://docs.microsoft.com/en-us/windows/desktop/Services/svc-cpp I wonder how can I integrate a vibe.d http server here: __gshared HANDLE ghSvcStopEvent = NULL; VOID SvcInit(DWORD dwArgc, LPTSTR* lpszArgv) { ghSvcStopEvent = CreateEvent(NULL, // default security attributes TRUE, // manual reset event FALSE, // not signaled NULL); // no name if (ghSvcStopEvent == NULL) { ReportSvcStatus(SERVICE_STOPPED, NO_ERROR, 0); return; } ReportSvcStatus(SERVICE_RUNNING, NO_ERROR, 0); // TO_DO: Perform work until service stops. while (1) { WaitForSingleObject(ghSvcStopEvent, INFINITE); ReportSvcStatus(SERVICE_STOPPED, NO_ERROR, 0); return; } } WaitForSingleObject will wait forever until ghSvcStopEvent will be filled (by extern (Windows) VOID SvcCtrlHandler(DWORD dwCtrl) nothrow). Do you have any proposal how to integrate vibe.d here? Kind regards André
Re: Windows Service
On Thursday, 15 November 2018 at 04:45:26 UTC, Soulsbane wrote: On Wednesday, 14 November 2018 at 19:38:08 UTC, Thomas wrote: Hi, I want to run a D program as a Windows service. After googl'in, I only found a very old project on github: https://github.com/tylerjensen/WindowsServiceInD Unfortunately, I wasn't able to compile it successfully. Does anybody know of newer approaches or even a template to start from? Thanks in advance, Thomas There is https://code.dlang.org/packages/daemonize I've only played with it a little on the Linux side so I'm not sure how good the windows service implementation is. I have just successfully compiled and started the hello-world example. It works (after fixing a small error) in Windows as well. Thanks a lot!
Re: Windows Service
On Wednesday, 14 November 2018 at 19:38:08 UTC, Thomas wrote: Hi, I want to run a D program as a Windows service. After googl'in, I only found a very old project on github: https://github.com/tylerjensen/WindowsServiceInD Unfortunately, I wasn't able to compile it successfully. Does anybody know of newer approaches or even a template to start from? Thanks in advance, Thomas There is https://code.dlang.org/packages/daemonize I've only played with it a little on the Linux side so I'm not sure how good the windows service implementation is.
Windows Service
Hi, I want to run a D program as a Windows service. After googl'in, I only found a very old project on github: https://github.com/tylerjensen/WindowsServiceInD Unfortunately, I wasn't able to compile it successfully. Does anybody know of newer approaches or even a template to start from? Thanks in advance, Thomas
Re: Windows DLL / Windows service
On Saturday, 7 June 2014 at 16:16:28 UTC, Etienne wrote: On Saturday, 7 June 2014 at 16:07:47 UTC, Adam D. Ruppe wrote: On Saturday, 7 June 2014 at 14:41:15 UTC, Etienne Cimon wrote: no documentation though. Any idea how to attach/detach with a known example? I'd also like to create a windows DLL that compiles through DMD/GDC/LDC with extern(c) so that folks from C++ can link with it . Check this out: http://wiki.dlang.org/Win32_DLLs_in_D should help you get started. Looks good ! I couldn't find a more recent example for a service but it should be similar I guess Hope this helps. https://github.com/duovia/WindowsServiceInD I'm using the Windows API library (source actually) on dsource.org. See link on the github page. I found it difficult to find a complete solution to the problem, so I'm going to cross post in a few places to make it easier to find for others seeking an answer to the same question.
Windows DLL / Windows service
Hello, I'm looking to compile a server into a windows service, and there doesn't seem to be any info out there except this : http://forum.dlang.org/thread/c95ngs$1t0n$1...@digitaldaemon.com It doesn't call rt_init, would that be the only thing missing from there? Also, the d runtime seems to have a windows dll module https://github.com/D-Programming-Language/druntime/blob/master/src/core/sys/windows/dll.d no documentation though. Any idea how to attach/detach with a known example? I'd also like to create a windows DLL that compiles through DMD/GDC/LDC with extern(c) so that folks from C++ can link with it .
Re: Windows DLL / Windows service
On Saturday, 7 June 2014 at 14:41:15 UTC, Etienne Cimon wrote: no documentation though. Any idea how to attach/detach with a known example? I'd also like to create a windows DLL that compiles through DMD/GDC/LDC with extern(c) so that folks from C++ can link with it . Check this out: http://wiki.dlang.org/Win32_DLLs_in_D should help you get started.
Re: Windows DLL / Windows service
On Saturday, 7 June 2014 at 16:07:47 UTC, Adam D. Ruppe wrote: On Saturday, 7 June 2014 at 14:41:15 UTC, Etienne Cimon wrote: no documentation though. Any idea how to attach/detach with a known example? I'd also like to create a windows DLL that compiles through DMD/GDC/LDC with extern(c) so that folks from C++ can link with it . Check this out: http://wiki.dlang.org/Win32_DLLs_in_D should help you get started. Looks good ! I couldn't find a more recent example for a service but it should be similar I guess