Issue Uploading Files from Rails app hosted on Elastic Beanstalk

后端 未结 3 1751
终归单人心
终归单人心 2021-01-12 15:40

I have a Rails 3 app that I\'m developing locally and deploying on Amazon\'s Elastic Beanstalk for production. There\'s several places in my app where images can be uploade

相关标签:
3条回答
  • 2021-01-12 16:15

    Hopefully fixed in the next version :)

    http://code.google.com/p/phusion-passenger/issues/detail?id=654

    0 讨论(0)
  • 2021-01-12 16:16

    After some research, I believe the problem is that a daily cronjob (/etc/cron.daily/tmpwatch) is removing the passenger-standalone.* directory that's critical for file uploads.

    I was able to get uploads working again by restarting the app server. For a more long term fix, I updated the tmpwatch script to exclude the pattern '/tmp/passenger*' (see below).

    #! /bin/sh
    flags=-umc
    /usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
            -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
            -X '/tmp/hsperfdata_*' -X '/tmp/passenger*' 10d /tmp
    /usr/sbin/tmpwatch "$flags" 30d /var/tmp
    for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
        if [ -d "$d" ]; then
            /usr/sbin/tmpwatch "$flags" -f 30d "$d"
        fi
    done
    

    Is there another solution that anyone else has found for this issue? I'm not a sys admin guy (which is a big reason why I chose to use Elastic Beanstalk), so I would prefer to not hack with the EC2 instance if at all possible - especially when my app scales and more instances are spawned.

    0 讨论(0)
  • 2021-01-12 16:19

    Have you considered direct uploading images into s3 instead? Uploads to the server in Elastic Beanstalk kind of go against the spirit of the thing (file can be deleted if the instance vanishes, the next request could be received by a different instance, etc). I'm not a sys-admin guy either and I'm using elastic beanstalk for the same reason.

    Basically I'm trying to say that by moving to uploading directly into s3 you should be able to leave your servers serving, your database basing the data and your file store store you files. Then hopefully you can be immune from this nonsense :)

    0 讨论(0)
提交回复
热议问题