Giter Site home page Giter Site logo

moomerman / zap Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 0.0 268 KB

⚡ Zap - A development web/proxy server that super-charges your development experience

License: MIT License

Go 94.26% HTML 5.74%
proxy webapp elixir phoenix ruby rails go buffalo hugo static-site

zap's Introduction

⚡ Zap - A development web/proxy server

About

Zap is a development web/proxy server that knows how to start and manage your development server processes, and provides SSL access to them.

Zap allows you to specify any command to start a backend server, we've tested it with:

  • Elixir/Phoenix
  • Ruby/Rails
  • Go/Buffalo
  • Go/Hugo
  • Simple Proxy
  • Static HTML

Features

  • SSL - creates a self-signed cert for each domain so you can test SSL in dev
  • Process management - start, monitor, spin down idle apps
  • Log watching - watches log files and restarts application on certain triggers
  • Works on macOS, Linux and Windows (some manual installation required on Linux & Windows)

Install

Either grab a binary for your platform from the Releases page or grab the code and build your own

go build -o zapd main.go # build the zapd binary
zapd -install # run the installer

Wishlist

  • Status UI

Credits

Inspired by pow (http://pow.cx/) and puma-dev (https://github.com/puma/puma-dev)

Development

To recompile the HTML templates, build and restart the server

pushd zap; go-bindata -pkg zap -o templates.go templates/; popd && go build -o zapd main.go && pkill zapd

zap's People

Contributors

azure-pipelines[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar moomerman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

zap's Issues

cached apps should be keyed by dir not hostname

Currently a loaded app is cached by the hostname referring to it, but since there could be multiple hostnames all pointing to the same app we should key on the app dir instead

zap/zap/app.go

Lines 183 to 187 in fb1329d

// TODO: apps should be keyed by Dir not host as you might have multiple
// hosts pointing to the same app
lock.Lock()
apps[host] = app
lock.Unlock()

better app availability check

We're currently looking for specific patterns in the log file to determine if an application has started but this creates a race condition. It would be better to see if we can connect to the port to determine availability.

Maybe even using a combination of the two, so wait for the log entry and/or check the port availability.

// replace tail with a generic function that just waits until the http port

also applies to Phoenix, Buffalo ...

Dependabot couldn't find a Gopkg.toml for this project

Dependabot couldn't find a Gopkg.toml for this project.

Dependabot requires a Gopkg.toml to evaluate your project's current Go dependencies. It had expected to find one at the path: /Gopkg.toml.

If this isn't a Go project, or if it is a library, you may wish to disable updates for it from within Dependabot.

HTTP port hangs

Any requests to the proxy over HTTP currently hang. Been wondering whether to pass through to the app or force redirect to HTTPS.

link command

Run link command in app dir and automatically create the symlink

eg. zap link mysite.dev creates symbolic link ~/.zap/mysite.dev linking to current dir

Dependabot couldn't find a Gopkg.toml for this project

Dependabot couldn't find a Gopkg.toml for this project.

Dependabot requires a Gopkg.toml to evaluate your project's current Go dependencies. It had expected to find one at the path: /Gopkg.toml.

If this isn't a Go project, or if it is a library, you may wish to disable updates for it from within Dependabot.

elixir/phoenix version detection

At the moment the presence of a mix.exs file assumes a phoenix 1.3 application. We should look at the dependencies and detect the version of phoenix - the only distinction at present is the command that is used to start phoenix < 1.3 is mix phoenix.server and >= 1.3 is mix phx.server.

$ mix deps | grep "phoenix "

phoenix 1.3.0-rc.2 (Hex package) (mix)

// TODO: look at the mix.exs file and determine which version of phoenix

Dependabot couldn't find a Gopkg.toml for this project

Dependabot couldn't find a Gopkg.toml for this project.

Dependabot requires a Gopkg.toml to evaluate your project's current Go dependencies. It had expected to find one at the path: /Gopkg.toml.

If this isn't a Go project, or if it is a library, you may wish to disable updates for it from within Dependabot.

apps not cleaned up when stopped in adapter

Couple of examples where this isn't working correctly:

In the phoenix adapter when you touch mix.exs it correctly kills the app for restart but doesn't remove it from the cache

If you forcefully kill an app that it says is has detected it and cleaned up but again it doesn't remove it from the cache

Might be easier just to detect on next request that the app is in the stopped state then cleanup & start a new one.

[linux] undefined reference to `launch_activate_socket'

When running go run main.go it crashes with the following error:

# github.com/moomernman/zap/vendor/github.com/puma/puma-dev/dev/launch
/tmp/go-build564753384/b129/_x002.o: In function `_cgo_f28cf972db4f_Cfunc_launch_activate_socket':
/tmp/go-build/cgo-gcc-prolog:55: undefined reference to `launch_activate_socket'
collect2: error: ld returned 1 exit status

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

github.com/moomerman/zap/dns: cannot find module providing package github.com/moomerman/zap/dns
github.com/moomerman/zap imports
	github.com/moomerman/zap/zap: cannot find module providing package github.com/moomerman/zap/zap

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

elixir/phoenix PORT env var check

If you don't configure phoenix correctly to allow PORT override then on startup it thinks the app hasn't started (because the app is running on port 4000 but it is checking the randomly assigned port for the service).

We need to handle this case, either by checking the configuration and/or by displaying a warning message.

automatic subdomain support

we should support all subdomains of configured hostnames, so if we have zap.dev we automatically support moo.zap.dev that points to zap.dev.

If moo.zap.dev exists then that would use that first, then fall back to zap.dev only if it doesn't exist.

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

github.com/moomerman/zap/dns: cannot find module providing package github.com/moomerman/zap/dns
	github.com/moomerman/zap/zap: cannot find module providing package github.com/moomerman/zap/zap

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot couldn't find a Gopkg.toml for this project

Dependabot couldn't find a Gopkg.toml for this project.

Dependabot requires a Gopkg.toml to evaluate your project's current Go dependencies. It had expected to find one at the path: /Gopkg.toml.

If this isn't a Go project, or if it is a library, you may wish to disable updates for it from within Dependabot.

one-click ngrok tunnel

If the user has ngrok (https://ngrok.com/) available on the command line (or by instruction to download), it would be nice if the zap interface had a one-click ngrok tunnel link that setup and configured a tunnel to that application in zap.

The idea would be that we have one ngrok instance that can be "moved" between your applications. Your app needs to be running then you visit /zap/ngrok and there you can one-click to start the tunnel. This would look at the current app config and start the ngrok instance (shutting down any existing ones pointing at other apps) with the app config, essentially creating a new 'app' that points to the same backend as the originating app, creates a symlink for the dynamically generated ngrok host pointing to the app in question (this way the routing will just work as expected).

One thing to note is that some backend application adapters may need to have a new instance created due to the new ngrok hostname, eg. the hugo adapter requires you to specify the full url as the baseURL when starting the app and then rewrites all internal URLs accordingly. If the app cache key is correctly configured then this should happen automatically.

UI

  • User visits /zap/ngrok
  • If tunnel is already running then show the current status log if it is for this app
  • If tunnel is running on another app then indicate this
  • Check to see if ngrok binary is available and instruct to install if not
  • If tunnel isn't running show a start tunnel link

Handlers

  • /zap/ngrok - shows the current status
  • /zap/ngrok/start - starts the ngrok tunnel for the current app
  • /zap/ngrok/stop
  • /zap/ngrok/restart ?

App

  • Check if tunnel exists, if so stop it and clean up
  • Start tunnel with ngrok http -host-header=mysite.dev --bind-tls=true 80
  • Capture the tunnel ID and create a corresponding symlink to the app (or proxy config)
  • Keep a reference to the tunnel in the AppConfig
  • Redirect to the ngrok URL - this should automatically route via the symlink and start an adapter - reuse an existing adapter if possible
  • When an app spins down, stop the tunnel and cleanup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.