herokutiddlywiki5

Why heroku app doesn't save new file with Tiddlywiki?



Have anyone met an issue like me before?
I have deployed TiddlyWiki5 to heroku as an app at https://jameswiki.herokuapp.com. It displayed and worked as expected at runtime. However, after the server (web dyno) sleeping and wakeup (often after 1 hour inactive), everything is clear.
I have checked my console in heroku when creating new Tiddle, it still said new Tiddle has been saved, but in fact, no new tiddle is saved to Tiddlers folder. Below is my script to install and run it:

In Package.json

{
    ...
    "scripts": {    
        "start": "tiddlywiki . --server",    
        "postinstall": "npm install -g tiddlywiki" 
    }   
}

In Procfile

web: tiddlywiki . --server $PORT $:/core/save/all text/plain text/html "" "" 0.0.0.0

Help me to fix this issue. Thanks.


Solution

  • Heroku's filesystem is ephemeral - it exists only while that dyno exists. When the dyno restarts or ends (as it does when the app goes to sleep), the new one will have a fresh, empty filesystem. If you want files to persist, you need to save them off to something like a database or Amazon S3 for long-term storage.

    https://devcenter.heroku.com/articles/dynos#isolation-and-security

    Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted. For example, this occurs any time a dyno is replaced due to application deployment and approximately once a day as part of normal dyno management.