Skip to content

zk/inky

Repository files navigation

inky.cc

A ClojureScript sketchbook.

Build Status

Working on Sketches Locally

Inky has a dev mode to work on sketches locally. Why? Sub-second (2-3s now, sub-second to return shortly) recompiles and source maps.

Just add the lein-inky plugin to your ~/.lein/profiles.clj like so:

{:user {:plugins [[lein-inky "0.1.7"]]}}

After that:

  1. Create a gist with a cljs file. Easy start: fork this gist.
  2. Clone that gist locally: git clone git@gist.github.com/<gist-id>.git
  3. cd <gist-id>
  4. lein inky. Once the server is running visit http://localhost:4659.

One gotcha, for source maps to correctly resolve your file, you must name it after the last part of the ns. For example, if the ns if your sketch is foo.bar.baz, name the file baz.cljs (in the root directory of the gist).

Starter gist to fork: https://gist.github.com/zk/8108564

Prereqs

Config

Env vars:

  • PORT -- web port to bind to
  • AWS_ACCESS_ID -- s3 creds
  • AWS_SECRET_ACCESS_KEY
  • AWS_S3_BUCKET -- s3 bucket to store compiled code
  • GA_TRACKING_ID -- Google Analytics
  • GA_TRACKING_HOST -- ex. 'inky.cc'
  • MONGO_URL -- DB connection url, mongodb:// format
  • GH_CLIENT_ID -- GH app creds
  • GH_CLIENT_SECRET
  • NUM_WORKERS -- Number of compile workers to spawn, defaults to 2

Dev

Copy bin/dev.sample to bin/dev, fill in appropriate env vars. Note that the env vars are only necessary if you're working on inky. If you're working on a sketch locally, only $PORT is required (provided by foreman).

Warning: There's a nasty bug where foreman won't correctly kill java processes it starts when foreman exits due to a child process exiting (this behavior doesn't manifest when you SIGINT foreman). You may need to manually kill previous processes manually.

Testing

Run bin/test

Deploy

Deploys to Heroku. Run bin/ship

  • Don't forget to bump inky's version number any time deps change (including dep version changes).

Bumping Versions

This should be done when new cljs libs are added, or the lein plugin is updated.

Places to bump:

  • project.clj
  • plugin/project.clj 2x
  • README.md
  • src/clj/inky/local.clj

If you're adding a new lib, don't forget to add it to inky.config/cljs-libs.

TODO

  • Report compilation progress on compile page
  • Handle s3 connection error / timeout (errors into compiling state right now).
  • Chart compile wait times
  • Compile times are looooooong, ~45-120 seconds on heroku, figure something out here.
  • Implement better way than newing Threads for spawning workers
  • Fix mobile experience

Internals

Job States

Inky runs several worker threads internally to compile gists, which pull from a job queue backed by MongoDB (:compile-jobs). Jobs transition through several states as they are compiled, and as errors pop up. All flags are unix timestamps unless otherwise specified.

  • Enqueued -- :created is set.
  • Compiling -- :created and :started are set.
  • Compile completed successfully -- :created, :started, and :succeeded are set.
  • Compile errored -- :created, :started, and :failed are set (see :error-cause for message).

This is a first cut on representing the different job states.

License

Copyright © 2013 Zachary Kim http://zacharykim.com

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.