uploading web.py app on Heroku - heroku

just started on using web.py and heroku, so...
I have this simple app that I want to upload to heroku and I have followed the instruction from http://joshuaoiknine.com/post/47196802362/publishing-for-the-web-py-python-framework-to-heroku
This is my Procfile:
web: python code.py $PATH
But after I uploaded it to heroku, it gives me the application error.
The heroku log shows me this:
2013-08-08T03:27:44.956675+00:00 heroku[web.1]: Starting process with command `python code.py /usr/local/bin:/usr/bin:/bin`
2013-08-08T03:27:45.673358+00:00 app[web.1]: Traceback (most recent call last):
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "code.py", line 52, in <module>
2013-08-08T03:27:45.673358+00:00 app[web.1]: app.run()
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/web/application.py", line 313, in run
2013-08-08T03:27:45.673358+00:00 app[web.1]: return wsgi.runwsgi(self.wsgifunc(*middleware))
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/web/wsgi.py", line 54, in runwsgi
2013-08-08T03:27:45.673358+00:00 app[web.1]: return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/web/net.py", line 76, in validip
2013-08-08T03:27:45.673358+00:00 app[web.1]: port = int(port)
2013-08-08T03:27:45.673552+00:00 app[web.1]: ValueError: invalid literal for int() with base 10: '/usr/local/bin:/usr/bin:/bin'
2013-08-08T03:27:46.866238+00:00 heroku[web.1]: Process exited with status 1
2013-08-08T03:27:46.881655+00:00 heroku[web.1]: State changed from starting to crashed
However, when i tried the second method, I receive this error:
Traceback (most recent call last):
File "code.py", line 55, in <module>
app.run(host='0.0.0.0', port=port)
TypeError: run() got an unexpected keyword argument 'host'
Any ideas how to get my app onto heroku up and running?

code.py expects an integer argument first, not your $PATH. It is probably a port it is expecting, so instead of $PATH in your Procfile pass $PORT.
Even better: change your code to use ENV["PORT"] and if that's not defined (as might be the case in your local dev env) then a default (say, 8000 or 8080 for your dev env).
On Heroku, the port your server needs to listen on is not fixed -- it changes with every restart of every dyno. Heroku will set the environment variable PORT to let you know which port to listen on.

Related

ERROR: for mysql a bytes-like object is required, not 'str' using docker-compose and laravel sail

I’ve rebooted my system and then run all my containers using the vendor/bin/sail up command, the only one that failed to reload was MySQL. The error is the following :
ERROR: for mysql a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 261, in _raise_for_status
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.25/containers/afdd1cbf7f45d9b20612bca
f73eef1b0bc1dd631bc6aa3dcfbf630c64e8a3662/start
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/compose/service.py", line 625, in start_container
container.start()
File "/usr/lib/python3/dist-packages/compose/container.py", line 241, in start
return self.client.start(self.id, **options)
File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File "/usr/lib/python3/dist-packages/docker/api/container.py", line 1095, in start
self._raise_for_status(res)
File "/usr/lib/python3/dist-packages/docker/api/client.py", line 263, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/usr/lib/python3/dist-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("b'Ports are not available: listen tcp 0.0.0.0:3306: bind: An attempt was made
to access a socket in a way forbidden by its access permissions.'")
I’m running this container on ubuntu server 20.04.
It might fix the problem if you provide an absolute path to your nginx/mysql conf file. I haven't tried the solution yet.

Heroku + Redis Cloud: Temporary failure in name resolution

I am using the Redis Cloud add-in on my Heroku application and I keep getting this error sporadically. I have tried flushing the redis DB and restarting dynos and that seems to fix it but I am curious why this is happening so often.
I am running worker dynos that use this redis DB and I am using python-rq to schedule jobs on the worker queues.
File "/usr/local/lib/python3.8/site-packages/redis/connection.py", line 563, in connect
raise ConnectionError(self._error_message(e))
2020-08-05T17:12:25.451733+00:00 app[worker_proc.5]: redis.exceptions.ConnectionError: Error -3 connecting to redis-13618.c73.us-east-1-2.ec2.cloud.redislabs.com:13618. Temporary failure in name resolution.
2020-08-05 17:12:25,461 INFO exited: worker_proc-0 (exit status 1; not expected)
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/redis/connection.py", line 559, in connect
sock = self._connect()
File "/usr/local/lib/python3.8/site-packages/redis/connection.py", line 584, in _connect
for res in socket.getaddrinfo(self.host, self.port, self.socket_type,
File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

Deploy Laravel on Cloud Foundry

I`m trying to deploy Laravel on Cloud Foundry, but at the end, it failed.
I followed this tutorial step by step. Also, I tried to solve my problem by this question but it doesn't work for me. And the overall view of my app is looks like this
However this is the errors, when I push the app to cf:
WARNING: A version of PHP has been specified in both `composer.json` and `./bp-config/options.json`.
WARNING: The version defined in `composer.json` will be used.
The extension 'fpm' is not provided by this buildpack.
The extension 'tokenizer' is not provided by this buildpack.
[ErrorException]
file_put_contents(/tmp/app/htdocs/bootstrap/cache/services.json): failed to open stream: No such file or directory
-----> Composer command failed
Traceback (most recent call last):
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/scripts/compile.py", line 50, in <module>
.from_build_pack('lib/additional_commands')
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/lib/build_pack_utils/builder.py", line 208, in extensions
process_extension(path, ctx, 'compile', process, args=[self])
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/lib/build_pack_utils/utils.py", line 69, in process_extension
success(getattr(extn, to_call)(*args))
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/extensions/composer/extension.py", line 414, in compile
return composer.compile(install)
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/lib/extension_helpers.py", line 154, in compile
self._compile(install)
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/extensions/composer/extension.py", line 181, in _compile
self.run()
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/extensions/composer/extension.py", line 316, in run
*self._ctx['COMPOSER_INSTALL_OPTIONS'])
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/extensions/composer/extension.py", line 360, in run
shell=True)
File "/tmp/buildpacks/ca44b1cd9a98d10d3246e577384a9145/lib/build_pack_utils/runner.py", line 109, in stream_output
raise CalledProcessError(retcode, cmd)
build_pack_utils.runner.CalledProcessError: Command '<open file '<fdopen>', mode 'w' at 0x7fa7340816f0>' returned non-zero exit status 1
Failed to compile droplet
Exit status 223
Staging failed: Exited with status 223
I need your help to solve this issue!

Heroku: no module named flask though it is in requirements.txt

Can anyone help with this error on Heroku?
2015-01-12T22:26:00.575669+00:00 heroku[web.1]: Starting process with command `python hangman.py`
2015-01-12T22:26:01.066240+00:00 app[web.1]: Traceback (most recent call last):
2015-01-12T22:26:01.066256+00:00 app[web.1]: File "hangman.py", line 3, in <module>
2015-01-12T22:26:01.066262+00:00 app[web.1]: from flask import (
2015-01-12T22:26:01.066268+00:00 app[web.1]: ImportError: No module named flask
2015-01-12T22:26:01.742444+00:00 heroku[web.1]: Process exited with status 1
2015-01-12T22:26:01.751614+00:00 heroku[web.1]: State changed from starting to crashed
My git repo is here: https://github.com/PJBentham/Hangman
I believe I have done everything correct as far as set up is concerned but I'm still getting the above error and can't figure out why?
You have to show the last or pull traceback to debug further ...! You git repo working perfectly fine.
From your traceback snippet flask is not there. Check if your app environ having flask or not using heroku run pip freeze

using rabbitmqadmin to access CloudAMQP / Heroku

I'm starting out to learn about AMQP and RabbitMQ.
To get myself going I have used a CLI tool, rabbitmqadmin, to successfully publish data to a RabbitMQ development install I have created upon my Mac OS X box. So far so good, I can publish messages, and watch them dequeue...
However when I come to try the exact same functionality upon the Heroku / CloudAMQP instance the rabbitmqadmin client seems to fall over.
This is the call:
rabbitmqadmin --host lemur.cloudamqp.com --vhost app4444444_heroku.com --user app4444444_heroku.com --password <withheld> publish routing_key=test payload="hello"
...and this is the output:
Traceback (most recent call last):
File "/usr/local/bin/rabbitmqadmin", line 828, in <module>
main()
File "/usr/local/bin/rabbitmqadmin", line 325, in main
method()
File "/usr/local/bin/rabbitmqadmin", line 428, in invoke_get
result = self.post(uri, json.dumps(upload))
File "/usr/local/bin/rabbitmqadmin", line 354, in post
return self.http("POST", path, body)
File "/usr/local/bin/rabbitmqadmin", line 377, in http
resp = conn.getresponse()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1013, in getresponse
response.begin()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 402, in begin
version, status, reason = self._read_status()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 366, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''
Any thoughts or ideas gratefully received!
Add --ssl to the command line. CloudAMQP's web ui is https only.

Resources