Closed frou closed 6 years ago
Hi Duncan. Let me mull this over a bit. I like the approach, and I wonder if there is an argument for making this more general - that is, whether the ability to write to a process's stdin rather than send a signal might be useful in other cases on all platforms.
Something to keep in mind is that it's probably a worthy goal for an identical modd.conf
file to"just work", whether the user is on Unix or Windows. Presumably we don't want to get into a situation where projects have both a modd-unix.conf
and modd-windows.conf
?
In that line of thinking, I can imagine the following as modd.conf
syntax:
Use a signal:
daemon +sighup: devd -m .
Use a message:
daemon |reload: devd -m .
Use a signal if the OS supports it, otherwise use a message:
daemon +sighup|reload: devd -m .
Remove all kits please
Since I'm no longer using Windows for development, I'm not fussed about this mechanism any more
Hi Aldo. We talked about this briefly a while back in this issue.
To recap...
Windows doesn't support signals. So, the feature of
modd
whereby it can be configured to communicate with daemons by sending signals to them does not work on Windows. The signals silently fail to do anything.(The exception to this is SIGKILL, which the Go runtime recognises the intent of, and uses a native Windows API to directly kill the target process).
I have added a feature I've called "Pipe Signals" to
modd
. I've made it so that it can only be enabled on Windows, because there's no need for it on other OSes where normal signals work fine.When Pipe Signals is enabled, daemons are started with a pipe connected to their STDIN. Instead of a signal being sent to the daemon, the textual name of the signal is written as a line on that pipe instead, e.g.
hangup\n
orinterrupt\n
.The daemon process can read its STDIN and take appropriate action. For example, I have also updated
devd
to be able to consume hangup in that way to cause a livereload on Windows.Currently the feature is disabled by default (enabled using
modd --pipesignals
).What do you think?