Skip to content

Instantly share code, notes, and snippets.

@RyanMulready
Created September 21, 2018 14:56
Show Gist options
  • Save RyanMulready/3fc887d4886ec76b89fd292fdd57f4d4 to your computer and use it in GitHub Desktop.
Save RyanMulready/3fc887d4886ec76b89fd292fdd57f4d4 to your computer and use it in GitHub Desktop.
My Procfile
django: es-site/es/manage.py runserver 0.0.0.0:8000
compass: compass watch es-site/es/es/static
mail: maildev
log: tail -f local_es.log
storybook: yarn --cwd es-site/selfserve/ styleguide
@tomleo
Copy link

tomleo commented Sep 21, 2018

In my .bash_alias file I've created aliases for all the various commands.

es_source_path=/home/tom/hacking/energysage/env11/bin/activate
alias esenv="export DJANGO_SETTINGS_MODULE='es.settings.local_dev' && source $es_source_path"
alias esrunserver="esenv && python /home/tom/hacking/energysage/es-site/es/manage.py runserver 0.0.0.0:9000"
alias esmail="maildev"
alias esolr="cd /home/tom/hacking/energysage/apache-solr-3.6.2/example && java -jar start.jar"
alias es="cd /home/tom/hacking/energysage/es-site/es"
alias esdata="source /home/tom/hacking/energysage/es-data-tools/env/bin/activate && cd /home/tom/hacking/energysage/es-data-tools"
alias escelerybeat="source $es_source_path && celery -A es beat"
alias escelery="source $es_source_path && celery -A es worker --loglevel=info"
alias esjs="cd /home/tom/hacking/energysage/es-site/selfserve/ && yarn dev --env.djangoURL='localhost:9000'"
alias esroot="cd /home/tom/hacking/energysage"
alias esvim="gvim -c 'Prosession ~/hacking/energysage/es-site/es'"
alias esinit="source $es_source_path && cd /home/tom/hacking/energysage && hivemind Procfile"

This makes it very easy to navigate and start various services.

My Procfile is as follows:

sass: compass watch /home/tom/hacking/energysage/es-site/es/es/static
mail: maildev
celery: celery -A es --workdir=/home/tom/hacking/energysage/es-site/es worker -Q long,nonurgent,celery --loglevel=info
log: tail -f /home/tom/hacking/energysage/local_es.log

I then run esrunserver in another terminal pane/window. If I'm doing pikachu work I simply open another window and type esjs.

@bhrutledge
Copy link

bhrutledge commented Sep 21, 2018

Here's my Procfile, followed by instructions on how to use it.

django: cd es-site/es && python manage.py runserver --settings es.settings.local_dev 8001
bsync: wait-on tcp:8001 && browser-sync start --proxy 127.0.0.1:8001 --files "es-site/es/es/**/*.+(css|js|html)" --port 8000 --no-open
log: tail -f local_es.log
sass: compass watch es-site/es/es/static
mail: maildev --web 8025
celery: celery --app=es worker --beat --loglevel info
flower: celery --app=es flower --port=8555
solr: cd solr/apache-solr-3.6.1/example && java -jar start.jar

This lives in the parent directory of es-site. I use overmind to run it; you can also use the lighter-weight hivemind.

Dependency installation on a Mac:

$ brew install overmind
$ npm install -g wait-on browser-sync maildev

Start all processes with overmind start, or selectively start with -l flag:

$ overmind start -l django,bsync,sass,mail
system | Listening at /Users/brian/Code/es-111/.overmind.sock
system | Tmux socket name: overmind-es-111-LD3VzZhS9K0xK1i73fLTMT
system | Tmux session ID: es-111
sass   | Started with pid 57230...
mail   | Started with pid 57232...
django | Started with pid 57235...
bsync  | Started with pid 57238...
django | /Users/brian/Code/es-111/es-site/es
mail   | MailDev webapp running at http://0.0.0.0:8025
mail   | MailDev SMTP Server running at 0.0.0.0:1025
sass   | Ignoring ffi-1.9.18 because its extensions are not built. Try: gem pristine ffi --version 1.9.18
sass   | >>> Compass is watching for changes. Press Ctrl-C to Stop.
django | Performing system checks...
django |
django | /Users/brian/Code/es-111/venv/lib/python2.7/site-packages/djgeojson/fields.py:12: UserWarning: `django-leaflet` is not available.
django |   warnings.warn('`django-leaflet` is not available.')
django | System check identified no issues (0 silenced).
django | September 21, 2018 - 15:48:00
django | Django version 1.11.12, using settings 'es.settings.local_dev'
django | Starting development server at http://127.0.0.1:8001/
django | Quit the server with CONTROL-C.
bsync  | [Browsersync] Proxying: http://127.0.0.1:8001
bsync  | [Browsersync] Access URLs:
bsync  |  -----------------------------------
bsync  |        Local: http://localhost:8000
bsync  |     External: http://10.1.10.46:8000
bsync  |  -----------------------------------
bsync  |           UI: http://localhost:3001
bsync  |  UI External: http://10.1.10.46:3001
bsync  |  -----------------------------------
bsync  | [Browsersync] Watching files...
sass   |  modified es-site/es/es/static/sass/selfserve.scss
sass   |     write es-site/es/es/static/css/selfserve.css
sass   |     write es-site/es/es/static/css/selfserve.css.map
bsync  | [Browsersync] File event [change] : es-site/es/es/static/css/selfserve.css

The ports are set up so that you can use http://localhost:8000 as usual. The page should reload on HTML and JS changes, while SASS changes should be injected without a reload. With some additional work, I think it's possible trigger a page reload when runserver reloads.

Worth noting that I've changed my Django logging configuration to write to the console, instead of local_es.log, which is why I didn't run the log process.

As I mentioned, I'd like to get this into the repo, as a baseline for local dev, especially for folks like Phil, Tommy, and interns that likely won't want to customize their environment.

@bhrutledge
Copy link

bhrutledge commented Sep 21, 2018

Also, I have a build task set up in VS Code, which means I can start my local server with Command+Shift+B:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "overmind",
            "type": "shell",
            "command": "(. venv/bin/activate; overmind start -l django,bsync,sass,mail)",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

@tomleo
Copy link

tomleo commented Sep 21, 2018

I should not I'm using hivemind not overmind.

@bhrutledge
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment