bengler / brow Goto Github PK
View Code? Open in Web Editor NEWA tool that configures unicorn and nginx locally for pebbles development
A tool that configures unicorn and nginx locally for pebbles development
When nothing is running, then starting a single project, e.g. snitch
with
$ brow start snitch
fails to start nginx.
This results in the following:
$ curl 'http://snitch.dev/api/snitch/v1/ping'
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /api/snitch/v1/ping was not found on this server.</p>
<hr>
<address>Apache/2.2.21 (Unix) DAV/2 Server at snitch.dev Port 80</address>
</body></html>
This is what happens:
$ brow watch
==> /tmp/brow-checkpoint.stderr.log <==
==> /tmp/brow-connector.stderr.log <==
==> /tmp/brow-dittforslag.stderr.log <==
==> /tmp/brow-grove.stderr.log <==
==> /tmp/brow-kudu.stderr.log <==
/Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.1/lib/guard/listener.rb:36:in `[]': can't convert Symbol into Integer (TypeError)
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/guard-0.9.1/lib/guard/listener.rb:36:in `select_and_init'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/brow-0.0.1/lib/brow/watcher.rb:46:in `watch'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/brow-0.0.1/lib/brow/watcher.rb:21:in `block in start'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/brow-0.0.1/lib/brow/watcher.rb:21:in `each'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/brow-0.0.1/lib/brow/watcher.rb:21:in `start'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/brow-0.0.1/lib/brow/wrangler.rb:81:in `watch'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/brow-0.0.1/bin/brow:74:in `watch'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/gems/brow-0.0.1/bin/brow:89:in `<top (required)>'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/bin/brow:19:in `load'
from /Users/bjoerge/.rvm/gems/ruby-1.9.2-p290/bin/brow:19:in `<main>'
So how do we get logging from Unicorn etc.?
Brow currently works only for OS X. These are the parts that are known to be platform specific at this point:
In hostsfile.rb
line 17 dscacheutil -flushcache
is used to flush the DNS-cache.
In nginx_config.rb
the method locate_mime_types finds the file mime.types
from the nginx bundle by looking in the folders used by popular OS X package managers (MacPorts, Homebrew)
Also some places I use backticks to call unix commands (like calling kill
to signal processes) while I should have used the Process api in ruby. I also use lsof
and ps
to find running processes and extract data about them. This makes brow vulnerable to the specific formatting of the output from these commands on a particular system. Brow would be more robust if it used more stable api's for this, but I have not researched if that is possible. This is particularly relevant in server_process.rb
.
In watcher.rb
the gem guard
is used to watch the file system. This should be platform independent, but might not be.
Also watcher.rb
looks for the command growlnotify
to display user notifications. Growl is an OS X specific application, but something similar may exist for linux?¨
Good luck!
# brow down
Killing nginx
Giving all unicorns a break ...
Stopping hermes, origo, vanilla, checkpoint
# brow up
Releasing master unicorns for checkpoint, hermes, origo, vanilla ...
Launching nginx.
Updating /etc/hosts
Done. Waiting for unicorn workers.
/Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/source.rb:801:in `rescue in load_spec_files': git://github.com/amedia/redcloth.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/source.rb:799:in `load_spec_files'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/source.rb:381:in `local_specs'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/source.rb:774:in `specs'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/lazy_specification.rb:53:in `__materialize__'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/spec_set.rb:86:in `block in materialize'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/spec_set.rb:83:in `map!'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/spec_set.rb:83:in `materialize'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/definition.rb:113:in `specs'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/definition.rb:158:in `specs_for'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/definition.rb:147:in `requested_specs'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/environment.rb:23:in `requested_specs'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:11:in `setup'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler.rb:116:in `setup'
from /Users/alex/.rvm/gems/ruby-1.9.3-p374@global/gems/bundler-1.2.3/lib/bundler/setup.rb:17:in `<top (required)>'
from /Users/alex/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/alex/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
+ hermes
+ vanilla
+ checkpoint
Got tired of waiting for origo.
You may try again soon or check syslog for errors.
What about a "brow update" that
It seems ruby is hardcoded to use 'sh'. In order to get shell_environment.rb to work as intended, try this:
bash -lc "command"
which should load .bash_profile and execute the command.
Homebrew's Nginx is not compiled with --with-http_gzip_static_module
or --with-http_stub_status_module
.
nginx: [emerg] unknown directive "gzip_static" in /tmp/brow/nginx/nginx.conf:29
nginx: configuration file /tmp/brow/nginx/nginx.conf test failed
and
nginx: [emerg] unknown directive "stub_status" in /tmp/brow/nginx/nginx.conf:47
nginx: configuration file /tmp/brow/nginx/nginx.conf test failed
When running
$ brow watch
Brow should watch the files of the running servers and reload them when files change. After the latest changes this stopped working. Someone should take a look and make it work again.
After brow down
completes, the Unicorn workers are still working.
The old behaviour where a single app handled all non-matching requests is broken.
# echo origo >~/.brow/default
# brow down; brow up
# curl "http://indrepuls.no.dev"
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>
A default backend should have been added to HAProxy config.
After the port to Ubuntu brow watch
is no longer automatically restarting services. It is not clear to me why this happens. Fedir?
Mappings in the nginx-config is naïvely based on the project folder name in the .brow-folder. The names should probably be downcased before it is passed to nginx.
At some point, implement hosts configuration with this?
brow does not work if the user has an alias for one of the shell commands it uses, e.g. ps
. Use full path (/bin/ps
) to avoid alias expansion.
En annen måte er å kjøre "shopt -u expand_aliases" før alle kommandoer. Da vil ikke bash bruke aliaser.
It would be nice to have some convenience tools to work with brow, for example to create a brow set, i.e. a ~/.project.brow
directory unibrow? for a single app with any dependencies (other apps/pebbles).
e.g.
brow new unibrow lifeloop --path ~/code/apps/lifeloop --pebblespath ~/code/pebbles --pebbles checkpoint papertime tiramisu
which would create a ~/.lifeloop.brow
dir with symlinks to lifeloop, papertime, tiramisu, and checkpoint
We'd also need brow use unibrow lifeloop
which would unlink an existing .brow
dir, and ln -s .lifeloop.brow .brow
# brow list
checkpoint (down)
hermes (down)
origo (down)
vanilla (down)
sh: /tmp/brow/haproxy.pid: No such file or directory
ps: option requires an argument -- p
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
[-g grp[,grp...]] [-u [uid,uid...]]
[-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
ps [-L]
nginx/haproxy (down)
A small bug makes brow prompt me to install a notification tool other than Growl. Please just recommend one notification system, and only one that works on the machine in question ;-)
There would be more convenient to have some cli command which would update all pebbles within .brow directory.
So it could do:
Brow up should sign off with a list of URLs taking you to a page that actually confirms that the pebble is running and also perhaps has its readme (or a link to such).
I founded brow failes when startin with empty hosts file. With this backtrace:
brow up
Releasing all unicorns ...
Nginx allready running, reloading config.
Updating /etc/hosts
/home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/brow-0.0.1/lib/brow/hostsfile.rb:11:in `update': undefined method `+' for nil:NilClass (NoMethodError)
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/brow-0.0.1/lib/brow/wrangler.rb:35:in `up'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/brow-0.0.1/bin/brow:16:in `up'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/gems/brow-0.0.1/bin/brow:89:in `<top (required)>'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/bin/brow:19:in `load'
from /home/robert/.rvm/gems/ruby-1.9.2-p290@brow/bin/brow:19:in `<main>'
It would be nice if brow could automatically create the apps' ./log
directory if it doesn't exists.
It would be veeeery nice if we could say
$ brow start .
in order to start the project (and all the dependencies) of the project in the pwd
.
Won't launch Nginx because config did not validate. Nginx had this to say about that:
nginx: the configuration file /tmp/brow-nginx-preflight.conf syntax is ok
nginx: [emerg] open() "/home/tom/.brow/.tiramisu.brow/tootsie/log/nginx-access.log" failed (2: No such file or directory)
nginx: configuration file /tmp/brow-nginx-preflight.conf test failed
Tell the user to remove the file /etc/resolver/dev (lovingly generated by pow).
Brow gets the name for the app from the symlink, but the name for the process from the pwd. Should only get the name from one or the other.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.