tj / mon

mon(1) - Simple single-process process monitoring program written in C
1.08k stars 94 forks source link

Windows equivalent #22

Closed cadorn closed 11 years ago

cadorn commented 11 years ago

I was wondering what it would take or if there is a windows equivalent for what mon does.

I am trying to get my toolchain running cross-platform and am looking for mon for windows.

tj commented 11 years ago

no clue

guybrush commented 11 years ago

maybe implement it with libuv, i was thinking about that for some time now but didnt even start anything yet since i am not very fluent in C

luislavena commented 11 years ago

@cadorn

I've implemented long ago for mongrel-service (a gem for old Mongrel webserver) some logic to launch and monitor background processes.

It was written in FreeBASIC:

https://github.com/luislavena/mongrel_service

What the service did (console process) is monitor every 5 seconds if the child process was terminated:

https://github.com/luislavena/mongrel_service/blob/master/src/mongrel_service/mongrel_service.bas#L124-L151

I've managed to refresh this code into something cleaner:

https://github.com/luislavena/service_wrapper

The implementation of ConsoleProcess is cleaner:

https://github.com/luislavena/service_wrapper/blob/master/inc/console_process.bi

But service_wrapper no longer restart the process if it dies:

https://github.com/luislavena/service_wrapper/blob/master/src/service_wrapper.bas#L69-L72

Checking running can be used.

service_wrapper is a naive approach to run Windows services. There are other tools like nssm that you might try too.

That of course, if you want to run things as service. If not, you could use console_process code and create something that mimics mon. Pretty much that is the building block.

Cheers.

cadorn commented 11 years ago

@luislavena Thanks a lot for your info. I'll have to take a look at that when this becomes a priority. Maybe someone will beat me to writing a mon-style wrapper before then ;)

tj commented 11 years ago

going to close for now, i wouldn't be able to maintain a windows thing anyway

luislavena commented 11 years ago

@visionmedia yeah, even if you wanted, mon codebase would get complicated to support both platforms and workaround Windows limitations. Perhaps someone can work on mon.exe that is CLI compatible.

@cadorn send me an email if you find interest in build such thing or issues with service_wrapper/mini_service libraries.