How do I stop my Mac OS X from going to sleep?
Go to sys pref -Energy

Slide the Computer and display sliders all the way to the right (to the never position)



If you prefer you can use the build in (by Apple) Terminal command "Caffeinate" to set specific non sleep modes.

https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man8/caffeinate.8.html