bash: worker:: command not found on koyeb - python

I tried to deploy this botto koyeb but I got this error
bash: worker:: command not found
ERROR: failed to determine the run command to launch your application: add a run command in your Service configuration or create a procfile in your git repository.
procfile in bot repo
worker: python -m bot
I have no idea what to do . need detailed help plz !

bash: worker:: command not found
The double : colon suggests that
you intended to run e.g. /usr/bin/worker
but bash attempted to execute /usr/bin/worker:
and found no file by that name.
Revise your command so it has fewer colons.

Related

My discord.py bot hosted on heroku does not work

I hosted my discord.py bot on heroku, Build Succeeded, and Deployed.
The code works on my VSC but not on heroku.
requirements.txt :
discord.py==1.3.4
PyNaCl==1.3.0
pandas
dnspython==1.16.0
async-timeout==3.0.1
Procfile :
worker: python bot.py
I don't know what is the problem.
Can please anyone tell me what to revise or what's wrong?
I appreciate your help.
I did :
$ heroku logs --tail
and I got :
2020-07-30T03:30:00.853064+00:00 app[worker.1]: File "bot.py", line 3, in <module>
2020-07-30T03:30:00.853284+00:00 app[worker.1]: import requests
2020-07-30T03:30:00.853316+00:00 app[worker.1]: ModuleNotFoundError: No module named 'requests'
2020-07-30T03:30:00.964329+00:00 heroku[worker.1]: Process exited with status 1
2020-07-30T03:30:01.011352+00:00 heroku[worker.1]: State changed from up to crashed
Sorry for the fool question.
To fix your issue it sounds like you need to add the requests module to your requirements.txt. To obtain this you can run the following command in your console:
pip show requests
Make a note of the version number and append the following to your requirements.txt file:
requests==x.y.z
Where x.y.z is replaced with the version you obtained from using pip show requests.
The general process of hosting a bot on Heroku:
If you want to host your bot on Heroku the steps I take are:
requirements.txt
You can obtain this by running the following command in your console:
pip freeze > requirements.txt
This will write all the required Python modules into the file for you with their respective versions. (This should also find and add your missing "requests" module)
Procfile
Inside this file, you will only need:
worker: python bot.py
"python bot.py" is what will be run on Heroku to start your bot. Although you have done this fine.
Heroku Resources
On the Heroku website access the dashboard for your app. Then select the "Resources" tab.
Next, there should be the contents of your Procfile. Click on the pen on the right hand side, enable the switch to allow Heroku to start the worker.
If you have any issues with hosting your bot, please reply to my suggestion and I'll be happy to help.

docker-compose error: "no such file or directory" on Windows

I am following along with this tutorial for running a Flask server using Docker. I am working on a Windows machine so I am using Docker Toolbox.
Once I enter the command to create the database table:
docker-compose run web /usr/local/bin/python create_db.py
I get the following error:
Error response from daemon: OCI runtime create failed:
container_linux.go:346: starting container process caused "exec:
\"C:/Program Files/Git/usr/local/bin/python\": stat C:/Program
Files/Git/usr/local/bin/python: no such file or directory": unknown
I am not sure why I am getting this error, any suggestions on how to fix this error would be greatly appreciated. Thank you.
The command fails because windows tries to parse the path, this can be circumvented by quoting the path:
docker-compose run web python create_db.py
If the above fails a double dash can be used:
docker-compose run web -- "/usr/local/bin/python create_db.py"
I had to change the current directory, and then to execute the script :
docker-compose run web bash -c "cd /usr/local/bin/; python create_db.py"

Running Django locally with heroku fails due to missing Procfile

I have a Django 1.11/Python 3.5 app that I built and want to run on Heroku locally. It's a simple SPA using the Heroku Django template provided on GitHub (https://github.com/heroku/heroku-django-template). I followed a Heroku tutorial (https://devcenter.heroku.com/articles/deploying-python#how-to-keep-build-artifacts-out-of-git), but I cannot seem to run the app locally using the following command:
heroku local web
Running this produces the following error:
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open '.env'
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:491:33)
at loadEnvsFile (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/lib/envs.js:133:15)
at Array.map (native)
at loadEnvs (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/lib/envs.js:148:30)
at Command.<anonymous> (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/nf.js:72:16)
at Command.listener (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/commander/index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:194:7)
at Command.parseArgs (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/commander/index.js:615:12)
My .env file looks like this:
WEB_CONCURRENCY=3
SECRET_APP_KEY="xxxxxxxxxxxxxxxxxxxx"
I ran chmod 777 on .env but I get the same error.
When I run the following command:
heroku local
I get the following error:
[WARN] EACCES: permission denied, open 'Procfile'
[FAIL] No Procfile and no package.json file found in Current Directory - See run.js --help
▸ Cannot convert undefined or null to object
My Procfile looks like this:
web: gunicorn personal_website.wsgi
Now I cannot understand why when running "heroku local web" I get the previously mentioned error, especially after giving it the necessary permissions.
Also, others have had the same error when running "heroku local", but the answer is to "make sure the formatting of your Procfile is correct." Well mine is correct and have tried many variations to it.
I have seen others with this issue on SO and some have been resolved, unfortunately for me none of them worked.
What could I possibly be doing wrong here?

I got an error while using git commit -m "Added a Procfile" on heroku

I'm using heroku for deploying a python-django project.I used git add . command and after that I gave git commit -m "Added a Procfile" .I got an error
error: pathspec 'a' did not match any file(s) known to git.
error: pathspec 'Procfile”' did not match any file(s) known to git.
My procfile is like this.
web: gunicorn resume.wsgi --log-file -
How can I solve this error?
Your error shows that you are somehow using curly quotes, not straight quotes. Type your command directly into the command window rather than copying and pasting from a doc.

Create Django Superuser on AWS Elastic Beanstalk

I have a custom user class called MyUser. It works fine locally with registrations, logins and so on. I'm trying to deploy my application to AWS Elastic Beanstalk and I'm running into some problems with creating my superuser.
I tried making a script file and run it as the official AWS guide suggests. Didnt work well so I decided to try a secondary method suggested here and create a custom manage.py command to create my user.
When I deploy I get the following errors in the log.
[Instance: i-8a0a6d6e Module: AWSEBAutoScalingGroup ConfigSet: null] Command failed on instance. Return code: 1 Output: [CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] command failed with error code 1: Error occurred during build: Command 02_createsu failed.
[2015-03-10T08:05:20.464Z] INFO [17937] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","truncated":"false","results":[{"status":"FAILURE","msg":"[CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] command failed with error code 1: Error occurred during build: Command 02_createsu failed","returncode":1,"events":[]}]}
[2015-03-10T08:05:20.463Z] ERROR [17937] : Command execution failed: [CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] command failed with error code 1: Error occurred during build: Command 02_createsu failed (ElasticBeanstalk::ActivityFatalError)
at /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:189:in `rescue in exec'
...
caused by: command failed with error code 1: Error occurred during build: Command 02_createsu failed (Executor::NonZeroExitStatus)
The code looks like the following:
This is my mysite.config file in .ebextensions/
01_syncdb and 03_collectstatic works fine.
container_commands:
01_syncdb:
command: "django-admin.py migrate --noinput"
leader_only: true
02_createsu:
command: "manage.py createsu"
leader_only: true
03_collectstatic:
command: "django-admin.py collectstatic --noinput"
option_settings:
- namespace: aws:elasticbeanstalk:container:python
option_name: WSGIPath
value: treerating/wsgi.py
- option_name: DJANGO_SETTINGS_MODULE
value: treerating.settings
This is my /profiles/management/commands/createsu.py file:
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from profiles.models import MyUser
class Command(BaseCommand):
def handle(self, *args, **options):
if MyUser.objects.count() == 0:
MyUser.objects.create_superuser("admin", "treerating", "password")
And I have __init__.py files in both /management/ and /commands/ folders.
I tried this command locally from command line and it works fine and creates the user without errors. So there shouldnt be any issue with the command itself or the MyUser.objects.create_superuser().
EDIT: I tried changing my def handle(): function to only set a variable to True and I still get the same errors. So it seems like the problem is not related to the create_superuser function or the handle, but more something with using manage.py.
Any ideas?
EDIT 2:
I tried executing the command by SSH and failed. I then followed the instructions in this post and set the Python Path's manually with:
source /opt/python/run/venv/bin/activate
and
source /opt/python/current/env
I was then able to successfully create my user.
The official AWS Django Deployment guide does not mention anything about this. But I guess you are suppose to set your Python Path's in the .config file somehow. I'm not sure exactly how to do this so if someone still want to answer that, I will test it and accept it as answer if that will solve the deployment errors.
Double-check the link to your secondary method. You can set the python path in the option settings (.ebextensions/02_python.config) that you've created:
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "iotd.settings"
"PYTHONPATH": "/opt/python/current/app/iotd:$PYTHONPATH"
"ALLOWED_HOSTS": ".elasticbeanstalk.com"
However, I've done this and am still experiencing the issue you've described, so you'll have to see if it fixes it.
EDIT: It turns out my issue was a file structure issue. I had the management directory in the project directory, when it should have been placed one level deeper in the directory of one of my apps.
This placed it one level deeper beneath my manage.py and settings.py than is shown in the example, but it is working fine now.
I know this could be late but I just wanted to share that I solved this issue by adding the file /profiles/management/commands/createsu.py into the app folder you are using.
In my case was:
easy/easyapp/management/commands/createsu.py
where easy is my project and easyapp my app.
Another alternative that worked for me is to just go directly into the config.yml file and change the wsgi path there. You can get access with the eb config command and just go down 50 lines or so, make your changes, escape and save. This is only an environment-specific solution though.

Categories