Reputation: 1466
I'm using Heroku to host a node application which keeps log in a file. Log is pretty much just timestamp and name of event that happen.
My question is if it is possible while deploying to ignore this file? I want to be able to deploy file once and after that have it on some ignore list so it never get's updated again with repo versions.
Workflow that I want to get:
Workflow so far is that the logs get rewritten into empty state because they are empty in github repo.
I've tried adding file to .slugignore but that deleted file from the Heroku server all together during next deployment and was not behaviour I wanted.
Is there any other solution for this, or do I have to resort to using database to save this?
Upvotes: 1
Views: 423
Reputation: 32629
It looks like you're looking for a .gitignore.
This file will allow you to ignore any file from GIT. You won't see them and won't have any chances of committing them. If they already exist in your git repository, they will remain as they currently are.
In order to ignore all files in the log folder, you can just add the following to this file:
logs/
For several example of gitignore files, GitHub has a very good repository: https://github.com/github/gitignore
If what you're looking for is to be able to keep a file updated on disk at runtime accross deploys and app restarts, this is not possible.
Each dyno is an independent container sharing nothing with the other ones. When your app is restarted or redeployed, the old running containers are stopped and destroyed, and your app is started on another server.
This means heroku has an ephemeral filesystem. Any file stored on disk cannot be expected to remain there once the web request has finished.
If this is a log file, you should be using heroku's logging pipeling, which will intercept all logs sent to STDOUT or STDERR.
For any file your app needs to store, you should use a dedicated file storage system like Amazon S3.
Upvotes: 1