Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run a simple file on heroku

Tags:

ruby

heroku

say I've got my rails app on github and am deploying the github repo on heroku.

I've got a situation where I have a simple text file with bunch of words (it is in my github repo). I want to insert these words (using a simple ruby program) into a database. Instead of using the tap command, is it possible in heroku to just run my simple ruby program and insert the words into the database...or maybe just show them on the terminal?

maybe confusing but basically I want to know how to run simple ruby script from heroku command line?

like image 434
ralph Avatar asked Dec 28 '10 04:12

ralph


People also ask

How do I run a Heroku script?

Running the App or bot on Heroku Now in order to turn on/execute our script, we have to open up our app on the Heroku Website, go to Resources, and hit edit on our worker. - Enable both the web and worker, then save. Note: It can take up to two minutes for the script to start running!

Can I write files to Heroku?

Heroku has an “ephemeral” hard drive, this means that you can write files to disk, but those files will not persist after the application is restarted. By default Active Storage uses a :local storage option, which uses the local file system to store any uploaded files.

How do I add a file to Heroku?

With Simple File Upload, you can add file uploading to your app with only two lines of code. We provide a prebuilt S3 setup with no javascript required. Simply add class = simple-file-upload to a hidden input.


2 Answers

With cedar, you can run bash:

heroku run bash
like image 195
Jords Avatar answered Oct 11 '22 06:10

Jords


Put your ruby script in a bin directory and git push it to Heroku. Now you can execute a shell command in the heroku console.

For example, if your Ruby script is bin/foo.rb, you can run the following command in the Heroku console:

`ruby bin/foo.rb`

Note the use of backticks.

like image 27
Steve Wilhelm Avatar answered Oct 11 '22 06:10

Steve Wilhelm