File System access

ToniTurek's Avatar

ToniTurek

04 Mar, 2019 10:33 AM

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?

  1. Support Staff 1 Posted by rune on 05 Mar, 2019 05:39 AM

    rune's Avatar

    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. 2 Posted by ToniTurek on 05 Mar, 2019 07:25 AM

    ToniTurek's Avatar
    pre { width: 92%; margin: 10px 2%; padding: 5px 2%; background: #efefef; border: 1px solid #d6d6d6 } blockquote { margin-left: 0; padding-left: 1em; border-left: 5px solid #ccc; }
    Rune,

    thanks for your quick response! I know that the files are always wiped if my app is redeployed. That’s why it creates restart files and up- and downloads them from an Amazon S3 bucket.

    Using putty would just be more convenient for checking these restart files and reading log files that implementing that all into my app.

    May I explain my app in more detail as you have suggested:
    Basically it’s a time parsing sport manager game. Users can register and manage a club. When the register phase is over, the game is started. Then, every minute a timer is called to increase the internal game time by - let’s say - an hour and to perform actions. That’s why the current state needs to be saved at every timer tick to be able to restore the state and all user inputs e.g. when an update of the app is performed.

    I recognized that the game timer is stopped after a while if I don’t access my app. Is it true that the app is closed completely after some time? If yes, is it possible to keep the game alive? This would be essential for this kind of app.

    Best Regards,
    Jan
    Am 05.03.2019, 06:39, rune <[email blocked]> schrieb:

    // Please reply above this line
    ==================================================

    From: rune (Support staff)

    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

    On Mon, Mar 04 at 02:33 AM PST, ToniTurek wrote:

    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?

    Having trouble reading this? View this discussion online: File System access.

    To unsubscribe and stop receiving emails from http://support.appharbor.com, visit this page

  3. Support Staff 3 Posted by rune on 07 Mar, 2019 01:26 AM

    rune's Avatar

    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. 4 Posted by ToniTurek on 08 Mar, 2019 07:51 PM

    ToniTurek's Avatar

    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

  5. ToniTurek closed this discussion on 30 Aug, 2019 12:34 PM.

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