dbashford / mimosa

A lightning-fast, modular, next generation browser development tool.
http://mimosa.io/
519 stars 34 forks source link

Autorestart Mimosa Express Server When server.coffee or files change #416

Closed ghost closed 9 years ago

ghost commented 9 years ago

Thought I'd leave this here for anyone it can help. This will restart mimosa watch -s every time server.coffee changes or any coffee file changes in your /routes/ directory, which is really nice if you are using a custom server like Express. This is confirmed working on OSX but should work on Linux and maybe Windows with some slight tweaking.

I first installed: https://github.com/emcrisostomo/fswatch

Then I created start.sh which contains the following:

#!/bin/bash
mimosa watch -s &
fswatch -r -o /path/to/server.coffee ~/path/to/routes | xargs -n1 -I{} ~/path/to/restart_mimosa.sh

Then I created _restartmimosa.sh:

#!/bin/bash
cd ~/path/to/your/project
killall -9 node
mimosa watch -s &

Once created just run ./start.sh

dbashford commented 9 years ago

There is also a mimosa-server-reload module :)

Sent from myMail for iOS

Friday, November 28, 2014, 6:59 PM -0500 from briaar notifications@github.com: Thought I'd leave this here for anyone it can help. This will restart mimosa watch -s every time server.coffee changes or any coffee file changes in your /routes/ directory. I first installed: https://github.com/emcrisostomo/fswatch Then I created start.sh which contains the following:

!/bin/bash

mimosa watch -s & fswatch -r -o /path/to/server.coffee ~/path/to/routes | xargs -n1 -I{} ~/path/to/restart_mimosa.sh Then I created restart_mimosa.sh :

!/bin/bash

cd ~/rarefy killall -9 node mimosa watch -s &

Once created just run ./start.sh — Reply to this email directly or view it on GitHub .

ghost commented 9 years ago

Oh, I saw that package but read: You must be using mimosa-server

I didn't think that would work for me since I'm using Express.

dbashford commented 9 years ago

mimosa-server works with any node server, and it's definitely a pre-req for server-reload. When you run with "-s" it's mimosa-server's job to start your server at the end of startup.

Run a quick "mimosa new projectName" and pick an express server and you'll get a simple project with all that wired up.

Sent from myMail for iOS

Friday, November 28, 2014, 8:35 PM -0500 from briaar notifications@github.com: Oh, I saw that package but read: You must be using mimosa-server I didn't think that would work for me since I'm using Express. — Reply to this email directly or view it on GitHub .

ghost commented 9 years ago

Thanks :-)