oTree Forum >

Problem with running on Heroku

#1 by Marti (edited )

Hi everyone, 

I have run an experiment (otree 3.4) some time ago on MTurk and we now want to replicate it on Prolific. 
I have checked and adjusted the code and checked locally and it works fine.
I have uploaded on Heroku following this guide (https://dallasnova.rbind.io/post/running-otree-on-prolific-for-beginners/) and I cannot seem to make it run. I have tried to reset the dataset, change the resources but I really do not understand what is going on. It works fine locally but not on Heroku.
I pasted below the log of the error. If any of you have an idea of what to do, it would be super helpful!

Thanks a lot!

When launching the app:
"Your database is not ready. Try resetting the database (Missing tables for auth.Group, otree.CompletedGBATWaitPage, CPR.Subsession, and 18 other models)."

Log:
" Build started by user sergio.loiacono673@gmail.com
2022-09-28T16:27:14.841719+00:00 heroku[web.1]: State changed from crashed to starting
2022-09-28T16:27:14.885520+00:00 heroku[worker.1]: State changed from crashed to starting
2022-09-28T16:27:14.558956+00:00 app[api]: Deploy a1d00ed9 by user sergio.loiacono673@gmail.com
2022-09-28T16:27:14.558956+00:00 app[api]: Release v374 created by user sergio.loiacono673@gmail.com
2022-09-28T16:27:17.071619+00:00 heroku[worker.1]: Starting process with command `otree prodserver2of2`
2022-09-28T16:27:17.047030+00:00 heroku[web.1]: Starting process with command `otree prodserver1of2`
2022-09-28T16:27:17.752278+00:00 heroku[worker.1]: State changed from starting to up
2022-09-28T16:27:18.764200+00:00 heroku[web.1]: State changed from starting to up
2022-09-28T16:27:18.542186+00:00 app[web.1]: Running on 0.0.0.0:31033 over http (CTRL + C to quit)
2022-09-28T16:27:19.007049+00:00 app[web.1]: Traceback (most recent call last):
2022-09-28T16:27:19.007065+00:00 app[web.1]: File "manage.py", line 10, in <module>
2022-09-28T16:27:19.007209+00:00 app[web.1]: execute_from_command_line(sys.argv, script_file=__file__)
2022-09-28T16:27:19.007228+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/otree_startup/__init__.py", line 181, in execute_from_command_line
2022-09-28T16:27:19.007470+00:00 app[web.1]: fetch_command(subcmd).run_from_argv(argv)
2022-09-28T16:27:19.007489+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
2022-09-28T16:27:19.007665+00:00 app[web.1]: self.execute(*args, **cmd_options)
2022-09-28T16:27:19.007683+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
2022-09-28T16:27:19.007844+00:00 app[web.1]: output = self.handle(*args, **options)
2022-09-28T16:27:19.007862+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/otree/management/commands/timeoutsubprocess.py", line 12, in handle
2022-09-28T16:27:19.007962+00:00 app[web.1]: Worker(port).listen()
2022-09-28T16:27:19.007979+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/otree/tasks.py", line 40, in __init__
2022-09-28T16:27:19.008117+00:00 app[web.1]: TaskQueueMessage.objects.filter(epoch_time__lt=time() - 60).delete()
2022-09-28T16:27:19.008134+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/query.py", line 711, in delete
2022-09-28T16:27:19.008376+00:00 app[web.1]: deleted, _rows_count = collector.delete()
2022-09-28T16:27:19.008393+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/deletion.py", line 294, in delete
2022-09-28T16:27:19.008556+00:00 app[web.1]: count = qs._raw_delete(using=self.using)
2022-09-28T16:27:19.008573+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/query.py", line 725, in _raw_delete
2022-09-28T16:27:19.008889+00:00 app[web.1]: return sql.DeleteQuery(self.model).delete_qs(self, using)
2022-09-28T16:27:19.008914+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/subqueries.py", line 75, in delete_qs
2022-09-28T16:27:19.009068+00:00 app[web.1]: cursor = self.get_compiler(using).execute_sql(CURSOR)
2022-09-28T16:27:19.009092+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1140, in execute_sql
2022-09-28T16:27:19.009698+00:00 app[web.1]: cursor.execute(sql, params)
2022-09-28T16:27:19.009723+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/otree/apps.py", line 65, in patched_execute
2022-09-28T16:27:19.009885+00:00 app[web.1]: raise ExceptionClass(msg).with_traceback(tb) from None
2022-09-28T16:27:19.009900+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/otree/apps.py", line 45, in patched_execute
2022-09-28T16:27:19.010055+00:00 app[web.1]: sql, params, many=False, executor=self._execute
2022-09-28T16:27:19.010072+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
2022-09-28T16:27:19.010178+00:00 app[web.1]: return executor(sql, params, many, context)
2022-09-28T16:27:19.010192+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
2022-09-28T16:27:19.010287+00:00 app[web.1]: return self.cursor.execute(sql, params)
2022-09-28T16:27:19.010301+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
2022-09-28T16:27:19.010398+00:00 app[web.1]: raise dj_exc_value.with_traceback(traceback) from exc_value
2022-09-28T16:27:19.010413+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
2022-09-28T16:27:19.010505+00:00 app[web.1]: return self.cursor.execute(sql, params)
2022-09-28T16:27:19.010567+00:00 app[web.1]: django.db.utils.ProgrammingError: relation "otree_taskqueuemessage" does not exist
2022-09-28T16:27:19.010567+00:00 app[web.1]: LINE 1: DELETE FROM "otree_taskqueuemessage" WHERE "otree_taskqueuem...
2022-09-28T16:27:19.010568+00:00 app[web.1]: ^
2022-09-28T16:27:19.010577+00:00 app[web.1]: - try resetting the database.
2022-09-28T16:27:19.000000+00:00 app[api]: Build succeeded
2022-09-28T16:27:28.285456+00:00 heroku[router]: at=info method=GET path="/" host=projects-otree.herokuapp.com request_id=4f995a0f-812d-4afb-973d-37baf903e422 fwd="147.12.231.22" dyno=web.1 connect=0ms service=46ms status=500 bytes=329 protocol=https
2022-09-28T16:27:28.281354+00:00 app[web.1]: ERROR Internal Server Error: /
2022-09-28T16:27:28.283482+00:00 app[web.1]: 10.1.1.227:17408 http "GET / 1.1" 500
2022-09-28T16:27:28.463895+00:00 app[web.1]: ERROR Internal Server Error: /favicon.ico
2022-09-28T16:27:28.466047+00:00 app[web.1]: 10.1.1.227:17530 http "GET /favicon.ico 1.1" 500
2022-09-28T16:27:28.468240+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=projects-otree.herokuapp.com request_id=371ec8a9-e6b7-46b4-b172-1e0319722933 fwd="147.12.231.22" dyno=web.1 connect=0ms service=17ms status=500 bytes=329 protocol=https
2022-09-28T16:26:49.000000+00:00 app[heroku-redis]: source=REDIS addon=redis-transparent-63406 sample#active-connections=1 sample#load-avg-1m=0.475 sample#load-avg-5m=0.55 sample#load-avg-15m=0.615 sample#read-iops=0 sample#write-iops=0.090909 sample#memory-total=16084924kB sample#memory-free=10024292kB sample#memory-cached=3288140kB sample#memory-redis=333744bytes sample#hit-rate=1 sample#evicted-keys=0"

Myrequirement.text:
"otree<5
sentry_sdk
psycopg2>=2.8"

#2 by Marti

Problem solved by resetting the database in the command line!

Write a reply

Set forum username