Can't save a temporary csv file to /home/app directory on heroku using R shiny app [duplicate] - heroku

I published my first simple app on Heroku with a free dyno. This app writes a simple .txt file, that seems to be correctly written because my API services are working fine.
But if I try to check this file by entering in the file system using "heroku run bash -a MYAPP", I can't see that file in the folder I thought to see. It is like the file is not existing. Can someone tell me why?
Thanks.

I found this on https://devcenter.heroku.com/articles/active-storage-on-heroku:
In addition, any files stored on disk will not be visible from one-off dynos such as a heroku run bash instance or a scheduler task because these commands use new dynos.
It is still not so clear to me, but at least I know it is a normal (but strange) behaviour of Heroku!

Related

Edit files on Heroku

I'm stuck at this simple task.
I have some configuration files that should be ignored by Git. But after commit to Heroku, I always get Application Error.
If I ignore those files then I have no way to get around the situation, but adding them to Git is definitely not a good idea.
Is there any way to ssh into Heroku server, I found no instructions on Heroku?
You can run a bash shell for your heroku app by doing this. Note that it will spin up another dyno, which will shut down when you exit the shell:
heroku run bash

how to create Heroku procfile for windows?

Im a newbie trying to make a django app, but unfortunately my os is windows.
Heroku docs is written for linux so I cant get sufficient information for app development on windows 7.
First how can I make procfile using window cmd?
Is there any command language translation docs?(linux->windows)
Regarding creation of text file in cmd shell:
echo web: run this thing >Procfile
this will create Procfile with web: run this thing inside (obviously).
Also You can use any text editor, notepad will fit perfectly.
And one thing, that wasn't obvious for me, therefore can also be helpfull to someone else.
Procfile should be a text file is a bit misleading, do NOT save Procfile as Procfile.txt or it will not be recognised. Just leave it plain and simple Procfile without any file format.
When you're using Windows for development, and your procfile contains for example $JAVA_OPTS (or anything else system dependent), then
besides of Procfile with Linux syntax (with for example: $JAVA_OPTS), for Heroku, you need
Procfile.windows with Windows syntax (where you can write for example" %JAVA_OPTS%), and you point to it while working with Heroku localy: heroku local web -f procfile.windows
A Procfile should be a text file, called Procfile, sitting in the root directory of your app.
It's the same for Windows or Linux or OS X.
It should specify the command Heroku should use to start your app - so it's not really about linux or windows.
So to answer your question: use a text editor. Any text editor.
Just create the file with name procfile. If your editor is intelligent enough as mine to understand the files like procfile have a Heroku icon
gunicorn doesn't work on Windows so you'll want a Procfile.windows that will locally host your app in a way that doesn't require gunicorn (such as the way you would normally do it).
web: ~what you would normally use to start your app~
web: gunicorn app_name.wsgi
write your own application name instead of app_name and file name just save without any Extention (Procfile).
A file named Procfile is required in the root of your Heroku project. The following is a basic example of the content to be created for a Django project:
web: gunicorn your_app_name.wsgi --log-file
Here the full docs from Heroku.

Download large files in Heroku

I am facing some issues when downloading large files in Heroku. I have to download and parse files greater than 1Gb. What I am trying to do right now, is use curl to download them into /tmp folder (of a Rails application).
The curl command is: "curl --retry 999 -o #{destination} #{uri} 2> /dev/null" and destination is Rails.root.join("tmp", "file.example")
The problem is that after a few minutes downloading, the "curl" process that is downloading the file is finished, way far from the download is finished. Before being finished, the logs show lots of "Memory exceeded". This led me to the thinking that when I am saving to /tmp folder, it is storing the downloaded content in the memory and when it memory hit its limit, the process is killed.
I would like to know if any of you have already experienced a similar issue on Heroku and if saving to /tmp folder really works like this. If so, do you have any suggestions to get this working at Heroku?
thanks,
Elvio
You are probably better off saving the file in an external cloud provider like S3 using the fog gem. In any case, Heroku is a read only filesystem, so they won't allow you to curl, must less write to it.

What's the simplest way to run a cron job on a standalone Ruby gem?

I have a gem that packages one .rb file containing my class and associated methods as well as a corresponding .bin file.
Locally, I can run everything just fine like so:
command_to_bin input_file output_file
I don't want to run this manually every day so I'm considering using cron on a server, but I'm a little unsure how to proceed.
Do I throw everything into a directory (.gem file, input file, output file) and just point the above cron command at the directory?
I've looked at this and sort of understand what's going on. I guess what confuses me the most is that when I look at all the web hosting providers, they mention domains and applications, but I just want to know how to have the standalone script run by itself without it being built into a web application or associated with a domain.
Check out the whenever gem. It's a wonderful gem to abstract all the nastiness of cron. Just include the command as you have written above and it should be fine.
You don't need to install Rails. After you wheneverize . the directory and set the schedule in your schedule.rb file, you need to run whenever --update-crontab to set everything to the system. Otherwise your cron jobs never get converted to Unix Cron

How to run my ruby file in heroku?

Sorry if i cannot make you understand, but this is how i understand and how i can tell you.
I am new to ruby and now i have learned a few and with that i have written a ruby code. It is actually to access the storageroom content management system from the form that i have done with ruby. And i used sinatra so i kept my stylesheet file in public folder and similarly i have a folder named storage_room_gem which i have to keep in the directory where my code is present.And another thing my code writes to a html file and it displays the html file.
Now i ran the code in my machine and it ran well. But i tried to run using heroku and it shows H10 error. what should i do?
By issuing the command
heroku logs --app <your appname here>
you can see the logs. The error should be listed there, as well as the stacktrace. If you post that, it makes it easier to help debug your code. Here is a link to more information on the heroku logs: https://devcenter.heroku.com/articles/logging#log_retrieval
Also, you can run it locally in a heroku-like environment using foreman. By running locally, you could have more tools at your disposal to investigate the error.
Here is a link to more information on foreman: https://devcenter.heroku.com/articles/procfile/#developing_locally_with_foreman

Resources