Preferred method to daemonize vagrant plugin

171 views Asked by At

Is there a preferred method to daemonize a vagrant plugin?

I am using vagrant-fsnotify which runs a process on the host to send file change events from the host to the guest.

3

There are 3 answers

0
toobulkeh On BEST ANSWER

Vagrant plugins have access to Vagrant "Action Hooks" which are useful for extending expected events.

For example, I could extend the fsnotify functionality to use Daemons for background-processing capabilities. Then, tie into the Vagrant Action Hook up and halt to trigger the start of fsnotify, and trigger the stop of fsnotify.

Here is a good example vagrant-plugin that uses action-hooks.

0
toobulkeh On

One potential would be to write a zsh/bash wrapper script to start the process on startup (if it's not already started) and stop it on machine death.

This would require the Daemons wrapper to daemonizie the process away from a shell

0
toobulkeh On

The Vagrantfile gets run every time the vagrant command is called. So you could throw specific ruby code in there, though that seems an anti-pattern.