This is my file structure:
requirements.txt
Procfile
Chess/
-- lichess-bot/
-- lichess-bot.py
-- config.yml
-- (many other files related to lichess-bot.py)
The part responsible to open the YAML in config.py
:
def load_config(config_file):
with open(config_file) as stream:
try:
CONFIG = yaml.load(stream)
except Exception as e:
print("There appears to be a syntax problem with your config.yml")
raise e
And in lichess-bot.py
here is the call for the config.yml
:
CONFIG = load_config(args.config or "./config.yml")
The commands I need to execute are
chmod +x ./engines/stockfish_10_x64
python lichess-bot.py -u
I tried this in Heroku bash: python ./chess/lichess-bot/lichess-bot.py -u
but it returns
FileNotFoundError: [Errno 2] No such file or directory: './config.yml'
I tried this Procfile
:
worker: cd chess
worker: cd lichess-bot
worker: chmod +x ./engines/stockfish_10_x64
worker: python lichess-bot.py -u
but Heroku couldn't recognize it.
If I do this manually:
~ $ cd chess
~/chess cd lichess-bot
~/chess/lichess-bot python lichess-bot.py -u
it work perfectly
How to access directories from Procfile
and then execute the file without errors?
The code defaults to a configuration file in the current directory named config.yml
:
CONFIG = load_config(args.config or "./config.yml")
You can move your config.yml
to the root of your repository, or you can provide args.config
. It looks like that can be done with --config
.
Your Procfile
should just define process types. They're not scripts, and they shouldn't contain many "steps". Something like
worker: python lichess-bot.py --config chess/lichess-bot/config.yml -u
should work (assuming your directory is actually called chess/
and not Chess/
). If you need to make the engine executable, consider doing that locally and committing it as an executable file.