Skip to content

Commit f8c11d1

Browse files
committed
Removed scheduler since it was unused and updated way to run app locally
1 parent ccc6947 commit f8c11d1

File tree

5 files changed

+29
-53
lines changed

5 files changed

+29
-53
lines changed

Diff for: Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
web: gunicorn manage:app
2-
worker: sh -c "python -u manage.py run_worker & python -u manage.py run_scheduler"
2+
worker: python -u manage.py run_worker

Diff for: README.md

+27-9
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,61 @@ A Flask application template with the boilerplate code already done for you.
1616

1717
## Setting up
1818

19-
1. Clone the repo
19+
##### Clone the repo
2020

2121
```
2222
$ git clone https://github.com/hack4impact/flask-base.git
2323
$ cd flask-base
2424
```
2525

26-
2. Initialize a virtualenv
26+
##### Initialize a virtualenv
2727

2828
```
2929
$ pip install virtualenv
3030
$ virtualenv env
3131
$ source env/bin/activate
3232
```
3333

34-
3. Install the dependencies
34+
##### Install the dependencies
3535

3636
```
3737
$ pip install -r requirements/common.txt
3838
$ pip install -r requirements/dev.txt
3939
```
4040

41-
4. Create the database
41+
##### Other dependencies for running locally
42+
43+
You need to install [Foreman](https://ddollar.github.io/foreman/) and [Redis](http://redis.io/). Chances are, these commands will work:
44+
45+
```
46+
$ gem install foreman
47+
```
48+
49+
Mac (using [homebrew](http://brew.sh/)):
50+
51+
```
52+
$ brew install redis
53+
```
54+
55+
Linux:
56+
57+
```
58+
$ sudo apt-get install redis-server
59+
```
60+
61+
##### Create the database
4262

4363
```
4464
$ python manage.py recreate_db
4565
```
4666

47-
5. Other setup (e.g. creating roles in database)
67+
##### Other setup (e.g. creating roles in database)
4868

4969
```
5070
$ python manage.py setup_dev
5171
```
5272

53-
6. [Optional] Add fake data to the database
73+
##### [Optional] Add fake data to the database
5474

5575
```
5676
$ python manage.py add_fake_data
@@ -60,9 +80,7 @@ A Flask application template with the boilerplate code already done for you.
6080

6181
```
6282
$ source env/bin/activate
63-
$ python manage.py runserver
64-
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
65-
* Restarting with stat
83+
$ foreman start -f Local
6684
```
6785

6886
## Project Structure

Diff for: app/utils.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from redis import Redis
2-
from flask import url_for, current_app
3-
from rq_scheduler import Scheduler
1+
from flask import url_for
42

53

64
def register_template_utils(app):
@@ -20,13 +18,3 @@ def is_hidden_field(field):
2018

2119
def index_for_role(role):
2220
return url_for(role.index)
23-
24-
25-
def get_rq_scheduler(app=current_app):
26-
conn = Redis(
27-
host=app.config['RQ_DEFAULT_HOST'],
28-
port=app.config['RQ_DEFAULT_PORT'],
29-
db=0,
30-
password=app.config['RQ_DEFAULT_PASSWORD']
31-
)
32-
return Scheduler(connection=conn) # Get a scheduler for the default queue

Diff for: manage.py

-29
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#!/usr/bin/env python
22
import os
3-
import time
43
from app import create_app, db
54
from app.models import User, Role
65
from redis import Redis
76
from rq import Worker, Queue, Connection
8-
from rq_scheduler.scheduler import Scheduler
9-
from rq_scheduler.utils import setup_loghandlers
107
from flask.ext.script import Manager, Shell
118
from flask.ext.migrate import Migrate, MigrateCommand
129

@@ -97,31 +94,5 @@ def run_worker():
9794
worker = Worker(map(Queue, listen))
9895
worker.work()
9996

100-
101-
@manager.command
102-
def run_scheduler():
103-
"""Initializes a rq scheduler."""
104-
conn = Redis(
105-
host=app.config['RQ_DEFAULT_HOST'],
106-
port=app.config['RQ_DEFAULT_PORT'],
107-
db=0,
108-
password=app.config['RQ_DEFAULT_PASSWORD']
109-
)
110-
111-
setup_loghandlers('INFO')
112-
scheduler = Scheduler(connection=conn, interval=60.0)
113-
for _ in xrange(10):
114-
try:
115-
scheduler.run()
116-
except ValueError as exc:
117-
if exc.message == 'There\'s already an active RQ scheduler':
118-
scheduler.log.info(
119-
'An RQ scheduler instance is already running. Retrying in '
120-
'%d seconds.', 10,
121-
)
122-
time.sleep(10)
123-
else:
124-
raise exc
125-
12697
if __name__ == '__main__':
12798
manager.run()

Diff for: requirements/common.txt

-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ webassets==0.10.1
2525
wsgiref==0.1.2
2626
redis==2.10.5
2727
rq==0.5.6
28-
-e git://github.com/ui/rq-scheduler.git@4e6837bb6a6e5be4ca364ff9d6218c2b2153009a#egg=rq-scheduler

0 commit comments

Comments
 (0)