File System access
My application is using temporary files to load a state if the app is restarted. I'm using Amazon S3 to permanenty store the files but for reading, I need them on the local file system.
Is there a way to investigate the local file system (for checking of existence, removing application files etc.) e.g. with Putty?
Discussions are closed to public comments.
If you need help with AppHarbor please
start a new discussion.
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac
Support Staff 1 Posted by rune on 05 Mar, 2019 05:39 AM
Hi,
You can't access the file system by other means than from your application code, but keep in mind that the filesystem is always wiped your app is redeployed (so that might be a way to trigger a reset in that sense if you need that). But it's relatively straightforward to check for the existence of files, and removing them if necessary, from your application code.
Can you perhaps tell me more about the use case though? I might be able to provide better advice with more information -- for instance, do you need to write files to the file system (which can be enabled from the "Settings" page for your app). Or are the files present in your repository but not your build output?
Best,
Rune
2 Posted by ToniTurek on 05 Mar, 2019 07:25 AM
Support Staff 3 Posted by rune on 07 Mar, 2019 01:26 AM
Hi Jan,
So applications on the free plan will recycle after 20 minutes of inactivity, but you can upgrade to the Catamaran and Yacht plans to get a higher idle timeout (currently 24 hours on the paid plans). That should significantly lower the likelihood your app will ever be recycled during low-traffic periods.
Generally speaking I'd probably recommend approaches to maintaining application state that doesn't require manually inspecting stateful files on the server. In fact, that's part of the reason we don't support that and by default only allow read access to the application's directory - it can sometimes be easier to do this during development, but for isn't scalable and will cause issues and largely unnecessary maintenance over time.
Instead of writing code to allow you to inspect log and state files written by your app on the server, you might want to consider implementing a solution that relies on a suitable database that can be shared among workers for this.
Perhaps the AWS S3 approach you've implemented so far can be used instead of this - it sounds like the app can already handle a redeployment by saving objects in S3, so why not do that every time the application is restarted? You could maybe achieve that simply by cleaning the entire repository that writes local state files on each application startup, and always download the files from S3 instead. It seems that'd address the problem you're facing with little modification needed, and furthermore less of a need to manually inspect those files on the server?
Best,
Rune
4 Posted by ToniTurek on 08 Mar, 2019 07:51 PM
Rune,
thank you very much for your support so far!
I have a follow-on questions:
Regarding the file upload to the AWD S3 storage, I'm using the following code:
uploadToS3(string BucketName, string Key, string File)
{
try {
PutObjectRequest putRequest = new PutObjectRequest {
BucketName = BucketName,
Key = Key,
FilePath = File,
ContentType = "application/zip"
};
PutObjectResponse response = client.PutObject(putRequest);
} catch (AmazonS3Exception e) {
writeLog("Error: " + e.Message);
} catch {
writeLog("Unknown Error");
}
}
The files I'm uploading are zip files.
This code is working if I start my app from my local Visual Studio. I can see the files on AWD and download them again. But if I upload the code to AppHarbor, it throws an unknown exception.
Do you have any hint to me what might be the problem?
Thanks in advance!
Jan
ToniTurek closed this discussion on 30 Aug, 2019 12:34 PM.