How to run my ruby file in heroku? - ruby

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

Related

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

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!

Heroku deployment error via codeship

I want to deploy django app to heroku via codeship and it generate an error and that is wget -O/dev/null http://something.herokuapp.com
How to fix the problem
Marko from the Codeship team here. Could you paste some more log output, or open a ticket on https://helpdesk.codeship.com?
Judging from the command you pasted above, I'd guess the check if the Heroku app, that you just deployed to, is running fails and this causes the build itself to fail.
Without any additional configuration we check the root URL for your application at http://HEROKU_APP_NAME.herokuapp.com via wget and see if it returns an HTTP/2xx or HTTP/3xx status code.
If it does, the check succeeds, else the build fails.
You can take a look at the script we use to perform the check at https://github.com/codeship/scripts/blob/master/utilities/check_url.sh

How can I get Heroku's database information in a ruby script?

I created a rails app that is hosted on Heroku. Now I want to upload a ruby script that will populate my database.
This script already exists and is using
PGconn.connect( :hostaddr=>"127.0.0.1", :port=>5432, :dbname=>"myDB", :user=>"MyUser", :password=>'MyPass');
This will obviously not work on Heroku.
I tried to get it using:
Rails.configuration.database_configuration
But I get
uninitialized constant Rails
How can I get the information so I can connect to my Heroku DB? Is there any way to make the same code wotk both on my localhost and on Heroku?
(ps: I am using foreman and the .ENV file, if it helps)
Edit:
The solution I took:
require 'yaml'
require 'erb'
config = YAML.load(ERB.new(File.read(File.join("config","database.yml"))).result)
In config I have all the information I need to perform the DB access.
Why would you not just access ENV['DATABASE_URL'] and break it up into the constituent parts? To see how this is done, if you do heroku run bash and do cat config\database.yml you will see how Heroku does this itself.
To ensure that locally it works as well if you execute via foreman run <Scriptname> then it will be executed and the contents of your .env will be loaded.

Using NGINX server to deploy a Meteor App from Amazon Linux AMI 2013.09.2 instance receive Module Error

I am attempting to deploy my first web application (a version of Telescope from the MeteorJS framework) via Heroku to a custom subdomain from a Amazon Linux AMI 2013.09.2 instance. I am following along with this tutorial - http://satishgandham.com/2013/12/a-complete-guide-to-install-production-ready-telescope-on-your-own-server/ - but once I attempt to run Telescope using PORT=3000 MONGO_URL=mongodb://localhost:3000/Telescope ROOT_URL=http://ec2-54-193-42-229.us-west-1.compute.amazonaws.com node client/main.js, I receive this error message: Error: Cannot find module '/home/ec2-user/bundle/programs/server/node_modules/fibers/client/main.js'
What I have attempted to do to solve this problem is performed cp || mv on the file main.js which is originally located in the ~/Telescope/client directory over to /home/ec2-user/bundle/programs/server directory and even '/home/ec2-user/bundle/programs/server/node_modules/fibers but I cannot seem to separate main.js from the /client directory. I am not sure if that is the issue or if there is some other underlying problem but I want to find a work around to using a proxy server at this point. I thought that moving the main.js file out of the /client directory was sufficient but apparently not. I am not sure it is imperative for my purposes to continue attempting to use a proxy but if there is a fix, I would not mind learning about it.
Or if any one could direct me on how this - https://github.com/aldeed/deploymeteor/ - could be a potential work-around to using an NGINX server proxy your help would be much appreciated.
You are getting the error because you are not running the command from your home folder.
You were at bundle/programs/server/node_modules/fibers.
Either use absolute path for client/main.js, or cd to ~
MONGO_URL=mongodb://localhost:3000/Telescope ROOT_URL=http://ec2-54-193-42-229.us-west-1.compute.amazonaws.com node client/main.js
PS: It will be helpful for others if you asked the question on the post itself, instead of here

WKHTMLTOPDF and "Error: Unable to create temporery file"

I've written a piece of code in PHP to generate PDF using WKHTMLTOPDF binary file. It was working fine till I had to recompile my Apache. Now it fails with error Error: Unable to create temporery file (this is the exact wording).
The situation in which the error is reproducible is a little complicated. I managed to narrow down the error and now I'm pretty sure that the error happens because of the user that Apache runs as. It seems to me that when WKTHMLTOPDF is running as a user with no home folder, it's unable to access a temporary folder within the user's home folder.
Surely I can change the Apache's user but I would rather resolve this problem once and for all. To this end it would be great if I could somehow set the temp folder for WKHTMLTOPDF or at least print its current value to make it valid! Does anyone know how to do any of these two?
BTW, I'm using WKHTMLTOPDF 0.11.0 rc1.
I saw the same error today in Rails4 + pdfkit gem(0.8.2) + wkhtmltopdf(0.12.2.1) under CentOS 6.7.
This error came from wkhtmltopdf and the reason was it couldn't create temporary file. wkhtmltopdf depends on some temporary filename creation API (I'm not sure), but probably following shows some hints:
$ man tempfile
$ man tempnam
In my case, my TMPDIR environment variable showed wrong path (I had accidentaly deleted the directory!) so that wkhtmltopdf couldn't create work file.
When I unset TMPDIR, then it worked! Of course, setting correct existence directory to TMPDIR should be OK too.

Resources