Issue Uploading Files from Rails app hosted on Elastic Beanstalk

情到浓时终转凉″ 提交于 2019-12-01 05:42:56

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.

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 :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!