Moral Of The Story Part 1
by Frank McPherson Sunday, July 10, 2016

Do not switch the server user ids that you use when starting storage.js because you may end up with files and directories to which storage.js doesn't have permissions to write. Here is how I made this mistake.

1. Originally started storage.js while logged in with my personal user id

2. Discovered the server was running slow, after attempting to stop storage.js, I rebooted the server

3. After the server came back up, I logged in as root installed some software, looked at some stats, and eventually started storage.js

4. I then accessed my 1999.io editor page, and started writing the posts below. The posts published as expected and almost all was well. 

5. Eventually, I shut down storage.js again, and the next time when I started storage.js I was logged in with my personal ID. After opening the editor I discovered that none of the changes I was making were being rendered. I confirmed the updates were being made to chatLog.json. 

I thought about the problem a bit, looked at the forever log for the session, and after seeing an EACESS error, did a ls -l of the directory and files that were created and noticed they were owned by root rather than my ID. Alas, the ID under which storage.js was running did not have permission to write to the directory. 

How did I fix this? 

I made a backup of chatLog.json, then logged back in as root and deleted the files and directories that were rendered with that ID. Then I logged in as myself, started storage.js, opened the editor and selected Main, Re-publish All Pages. At this point the directory was re-created under my ID and everything rendered as expected. I confirmed via terminal and ls -l that my ID owned all the directories and files.