Lecture 10: Heroku, Workers, and Postgres Flashcards

1
Q

What are the basic files needed to create a Heroku App?

A
  • Procfile
  • requirements.txt
  • runtime.txt
  • webapp.py
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the runtime file specify?

A

The language/runtime to use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the requirements file specify?

A

The modules/libraries to install in the environment –

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the Procfile file specify?

A

The command(s) we want to run when our application is deployed

  • Defines a process type (web/worker/clock)
  • Tell gunicorn to look for the webapp.py file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the webapp file specify?

A

The web application code

  • Consists of a single app() function definition
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which files help set up our application environment?

A
  • requirements.txt

- runtime.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the app() function in the webapp file do?

A

Hooks into WSGI and allows Python to specify a

response when receiving a request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What do we specify in the webapp file?

A
  • Data (streaming bytes)
  • Status (HTTP status code)
  • Response Headers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What commands do you run to create a new heroku deployment with Git

A
git init
git add .
git commit
heroku create
git push heroku master
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe the storage between processes

A
  • Individual processes are run in a semi-sandboxed manner

- They don’t have direct access to the same files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the database were using with Heroku?

A

PostgreSQL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you connect to PostgreSQL?

A

requirements. txt file:
- add ‘psycopg2’ line to

webapp. py file:
- In a try/except
- Define DATABASE_URL
- Create DB connection
- Create cursor
- Create table and execute query on cursor
- conn.commit()
- conn.close()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the command to scale workers to 1

A

heroku ps:scale worker=1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does heroku ps:stop worker do?

A
  • Puts the proccess into idle

- The process will keep on restarting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you kill a worker process?

A

Scale workers to 0

heroku ps:scale worker=0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly