Here is very simple way to setup immediate automatic upload of source code modifications to server via ssh. This gives you ability to perform live development and testing of your solutions. There are a lot of utilities to achieve this and you even can write some not-so-comlicated script doing recurrent compare of file modification times yourself – but there is very easy solution from Facebook, called watchman. To install it under OsX use Brew
1 |
brew install watchman |
Watchman will call upload script for each modified file – lets write this script and call it uploadauto.sh. It will be really short!
1 2 |
MYSERVER=11.22.33.44 scp $1 $MYSERVER:~/folder/on/server/$1 |
I assume you have ssh keys on server and don’t do manual password entry. Put this script into the folder you want to synchronise. And finally we need to say to watchman to look over this folder and call our script when something changes:
1 2 |
watchman watch /Users/me/project1 watchman -- trigger /Users/me/project1 upload '*.*' -- ./uploadauto.sh |
Replace here /Users/me/project1 with your folder name. upload is the name of the trigger. ‘*.*’ is the mask for files to be monitored. More information about trigger syntax can be found here.
And thats all!