Tuesday, March 31, 2015

Running Mac as a production server

For one of my open source projects we were given a server, a mini mac to be precise. Sure, we could have put linux on it, but because all the stack we are using runs on Mac so we decided we could probably use this server, why not. We sent it to a mac mini server farm to host it.

Image result for mac mini server 2013

There were a few wrinkles.

Sleep.
We delegated the server setup to an intern so they could learn how to set up the machine, they forgot to turn off sleep so the server was oddly unresponsive for the first week or so of testing.

Updates.
Macs like updating, and they seem to use RAM to do so. If you don't update the server you can have a significant chunk of your RAM hanging out waiting for you to do the update. We haven't figured out how to accept XCode downloads from the apple store, so this means we had to learn how to turn on VNC.

Turning on VNC
sudo  /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw mypasswd -restart -agent -privs -all

Turning off VNC

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off


Using pm2 vs forever
At the same time we did the upgrade, we decided wouldn't it be nice to have a new node process manager? So we switched our webservices to use pm2. After a month of sleep like behavior, after we had solved the sleep like behavior, we decided maybe switching process managers at the same time as switching OS was a bad idea. We switched back to forever and now the server is almost normal.

These were a few reasons why we regret using the Mac server instead of formatting it with Linux, although now that its sort of stable with ~97% uptime we aren't planning formatting it just yet.

No comments: