1. restart the process in case of  server exception

2. refactor facebook.js code