Coder Social home page Coder Social logo

fresh's Introduction

unmaintained

Fresh

Join the chat at https://gitter.im/pilu/fresh Build Status

Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file.

If the web framework you are using supports the Fresh runner, it will show build errors on your browser.

It currently works with Traffic, Martini and gocraft/web.

Installation

go get github.com/pilu/fresh

Usage

cd /path/to/myapp

Start fresh:

fresh

Fresh will watch for file events, and every time you create/modify/delete a file it will build and restart the application. If go build returns an error, it will log it in the tmp folder.

Traffic already has a middleware that shows the content of that file if it is present. This middleware is automatically added if you run a Traffic web app in dev mode with Fresh. Check the _examples folder if you want to use it with Martini or Gocraft Web.

fresh uses ./runner.conf for configuration by default, but you may specify an alternative config filepath using -c:

fresh -c other_runner.conf

Here is a sample config file with the default settings:

root:              .
tmp_path:          ./tmp
build_name:        runner-build
build_log:         runner-build-errors.log
valid_ext:         .go, .tpl, .tmpl, .html
no_rebuild_ext:    .tpl, .tmpl, .html
ignored:           assets, tmp
build_delay:       600
colors:            1
log_color_main:    cyan
log_color_build:   yellow
log_color_runner:  green
log_color_watcher: magenta
log_color_app:

Author

More

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

fresh's People

Contributors

alex-tan avatar aussiegeek avatar chr1sbest avatar cryptix avatar dohe avatar ernestas-poskus avatar gitter-badger avatar gmccue avatar gravityblast avatar ivpusic avatar mattn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fresh's Issues

Custom commands on build

I've been playing with fresh a bit lately and i'm loving it. I'd really like to see something in the config that allows me to run my own custom commands when changes occur.

An example might be to run ctags.

Watcher crashes when using a different root in config

I was trying to set fresh up in a project that has a structure like this:

myProject/
    public/
        index.html
        ...
    src/
        files.go
        ...
    scripts/
        fresh.runner.conf

I made a config that sets the root to: .domain.com/me/myProject/src

Then I change into the myProject location and run: `fresh -c scripts/fresh.runner.conf``

The watcher crashes with:

Loading settings from scripts/fresh.runner.conf
16:30:05 runner      | InitFolders
16:30:05 runner      | mkdir ./tmp
16:30:05 runner      | mkdir ./tmp: file exists
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x43e51c]

goroutine 1 [running]:
runtime.panic(0x4fdc00, 0x659ce8)
    /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/pilu/fresh/runner.func·005(0xc2100640d3, 0x2b, 0x0, 0x0, 0x7f20247ea238, ...)
    /path/to/go/src/github.com/pilu/fresh/runner/watcher.go:41 +0x2c
path/filepath.Walk(0xc2100640d3, 0x2b, 0x55d160, 0x4, 0xc2100661b0)
    /usr/local/go/src/pkg/path/filepath/path.go:378 +0x81
github.com/pilu/fresh/runner.watch()
    /path/to/go/src/github.com/pilu/fresh/runner/watcher.go:50 +0x6b
github.com/pilu/fresh/runner.Start()
    /path/to/go/src/github.com/pilu/fresh/runner/start.go:110 +0x32
main.main()
    /path/to/go/src/github.com/pilu/fresh/main.go:35 +0x16c

My hope was that I could monitor both the public/ static files, along with the go source in the sub directories.

Thanks!

Silent failure when there is a public directory

I'm seeing a strange bug where if I create an empty directory called public in my project root, fresh outputs the following but never executes my application's main function:

app_1   | 16:33:50 runner      | InitFolders
app_1   | 16:33:50 runner      | mkdir ./tmp
app_1   | 16:33:50 runner      | mkdir ./tmp: file exists
app_1   | 16:33:50 watcher     | Watching .
app_1   | 16:33:50 watcher     | Watching handlers
app_1   | 16:33:50 watcher     | Watching models
app_1   | 16:33:50 watcher     | Watching public

This doesn't happen if I create an empty directory with a different name.
Perhaps I would be able to use #19 as a work around if it were merged?

tmp/ folder

Hello.

At each re-build I'm getting an error:

remove tmp/runner-build-errors.log: no such file or directory

Indeed when I check the tmp/ folder there is binary named runner-build.

Is this normal behavior? I'm on Mac Yosemite with Go 1.5.

Regards.

Vagrant shared folder?

I'm trying to build y app in a Vagrant box with shared folder between the VM and my local computer. However Fresh doesn't seem to rebuild when I edit files locally.

Has anyone experienced something similar?

fresh: command not found on windows

I am trying to run this on Windows 7. It returns this:
fresh: command not found

I have a config file. I don't know any other step to run it even after reading readme file.
And i did this;
go get -u github.com/pilu/fresh

What should i do to simply run it.

go get returning an error

Hi,

When I try a go get github.com/pilu/fresh I get the following error:

image

Any idea how I fix this? Thanks.

question

fresh is neat thanks. Really liking golang

Its a tool, and so is not imported into my project code.
i use glide for vendoring. works well with golang 1.5 so far.

Now, my question is:
How can i ensure that fresh is installed as a tool for each project ?
One way is to make it a "cmd" in my project maybe... Not sure.

Double restart?

Using fresh with a small Go server on OS X. Whenever I save a file, fresh recompiles and restarts the application twice. Is this common? How to troubleshoot this?

Other than this small issue, really enjoying the tool. Please keep it up!

Is there any way to ignore output from fresh?

I think there are too much debug info from fresh, it couldn't be ignore and added prefix strings to my output. It makes debug more harder.
There should be an option to mute fresh.

Change default tmp/ and tmp/runner-build from root to working user

I've noticed that in a project's folder with 0755 permissions where fresh is being run, tmp folder can't be created. Temporarily giving this folder 0777 solves the issue, but the tmp folder is creates from root:root user and group (and you can't anymore delete this folder if not root or sudo), so I guess that's the problem.

If I try to create tmp folder manually, fresh doesn't run with this folder as:

open tmp/runner-build: permission denied

Once again, I need to 0777 that folder even from my working user... But the runner-build file still belongs to root.

App is rebuilt every time a file is opened in editor

I am using Atom editor with other Golang plugins.

When I have a project directory open in sidebar, every time I open new file to edit by selecting from sidebar, fresh runs the rebuild process.

I tried with other text editors too, and every time a file is opened, fresh runs rebuild.

Can we restrict it to only save event of the file?

FYI, none of the editors have autosave or similar feature(s) enabled.

Ignore some paths

Have a setting that can allow you to ignore some directories from being watched.

It can sometimes be the case that not all folders contents should force a reload of the entire application.

inotify_init: too many open files

Hi, I got issue after adding so many js dependencies in my project folder thru npm.
my question is how to ignore some specific folder(s) to avoid this kind of error ?

inotify_init: too many open files

image

Thanks in advance,

Performance suggestion

I wait a long time for the first time to load it. I got a lot of messages which I do not care about

image

From my own expirence I know that a log takes a lot of time. So, it may be a good suggestion to not display the ignored directories, but just the ones that I am interested in wathcing

What do you think?

Adjust logging verbosity?

Is there a setting for this? It looks like there isn't anything referenced in the config file.

The reason I'm asking is that I have a vendor directory, and fresh logs everything in there on startup, like so:

12:52:11 watcher     | Watching .
12:52:11 watcher     | Watching vendor
12:52:11 watcher     | Watching vendor/github.com
12:52:11 watcher     | Watching vendor/github.com/julienschmidt
12:52:11 watcher     | Watching vendor/github.com/julienschmidt/httprouter
12:52:11 watcher     | Watching vendor/github.com/kelseyhightower
12:52:11 watcher     | Watching vendor/github.com/kelseyhightower/envconfig
...

There's also a bunch of what looks like debug output about receiving events, checking for file existence, etc.

It looks like you've got these logs nicely separated into different loggers already from the output, so I guess what I'm really asking for is a way to only see the output from the build and runner loggers.

Error getting from github repo

Hi, I'm getting the following error:

go get github.com/pilu/fres

# github.com/pilu/fresh/runner
..\..\..\..\!gopath\src\github.com\pilu\fresh\runner\start.go:92: undefined: syscall.Rlimit
..\..\..\..\!gopath\src\github.com\pilu\fresh\runner\start.go:95: undefined: syscall.Setrlimit
..\..\..\..\!gopath\src\github.com\pilu\fresh\runner\start.go:95: undefined: syscall.RLIMIT_NOFILE

Any ideas as to why this is happening?

Note: !gopath is my %GOPATH%

Error: too many open files

The project I am trying to use Fresh with uses AngularJS for everything UI-related (no use of html/template anywhere), and Fresh dies when it tries to descend into the directory containing all of the AngularJS stuff.

I tried to restrict which files Fresh looks at by setting valid_ext: .go in a custom config file, however Fresh still fails like so:

$ fresh -c=fresh.conf
Loading settings from fresh.conf
12:10:09 runner      | InitFolders
12:10:09 runner      | mkdir ./tmp
12:10:09 runner      | mkdir ./tmp: file exists
12:10:09 watcher     | Watching .
12:10:09 watcher     | Watching old-data
12:10:09 watcher     | Watching www
12:10:09 watcher     | Watching www/app
12:10:09 watcher     | Watching www/app/css
12:10:09 watcher     | Watching www/app/fonts
12:10:09 watcher     | Watching www/app/img
12:10:09 watcher     | Watching www/app/js
12:10:09 watcher     | Watching www/app/lib
12:10:09 watcher     | Watching www/app/lib/angular
12:10:09 watcher     | Watching www/app/lib/angular/i18n
too many open files

syscall undefined installing on windows 7

PS C:\Users\shxu\Dropbox\go\src\poem> go get github.com/pilu/fresh

..\github.com\pilu\fresh\runner\start.go:92: undefined: syscall.Rlimit
..\github.com\pilu\fresh\runner\start.go:95: undefined: syscall.Setrlimit
..\github.com\pilu\fresh\runner\start.go:95: undefined: syscall.RLIMIT_NOFILE

runner-build not getting killed when fresh exits

I've been using fresh for several years and it's worked perfectly (thank you)! However, I recently encouraged co-workers to use it and their fresh installs leave the runner-build process running when fresh exits (when they kill fresh using control-c). Any ideas what's going wrong? One co-worker is running on mac and another on ubuntu. The runner.conf contains just ignored: vendor

Dockerized !

Hi,
It's not an issue, just to say that I'm using a docker container I've made and finally gave it to the community:
https://hub.docker.com/r/metal3d/go-fresh/

You may try, it works like a charm at home. It's nice to work with other containers as linked mongo database by docker-compose. I'm using "Glide" to get "vendor" directory in my project, no need to install them in the container now.

How to use (MacOSX)

I followed the instructions.

I used go get -> No errors.

Yet when I cd to my go programs path and type "fresh" it says: -bash: fresh: command not found

Do I need to change my PATH ENV VARIABLE to point to somewhere specific?

abandoned?

Hey @pilu - just wondering if you're no longer supporting fresh? .. it's a great project and my team uses it everyday (my fork though, since its quite stale) .. whats up?

"(MISSING)" when encoding values

When encoding values, an error occurs. The value "@" is not encoded and just comes back with (MISSING). This was tested apart from fresh and it works correctly with go run

func test() {
	v := url.Values{}
	v.Set("email", "[email protected]")
	log.Println(v.Encode())
}

Response using fresh:
email=test%!t(MISSING)est.com

Intended Response:
email=test%40test.com

too many open files issue

i always face this issue when i run this command

"inotify_init: too many open files"

any suggestions ?

Cross-Compile

Is there any flags to specify the exact build parameters:

I run a mac but I want to build a linux executable.
I use this command:

GOOS=linux GOARCH=amd64 go build -o main.linux main.go

fresh: command not found on Ubuntu

I installed fresh using go get and I see it being placed at ~/go/src/github.com/pilu/fresh.

echo $GOPATH
/home/me/go

I can build and run my project at ~/go/src/myapp, but as for fresh I get:

me@pc:~/go/src/myapp$ fresh
fresh: command not found

How can I fix this?

Running fresh is stuck hanging on "waiting for loop 2"

I have done nothing to my machine and this was working two days ago. Now I am stuck waiting on loop 2. Has anyone else had a similar issue?

I have killed everything running on localhost:3000 so nothing should be hindering it from listening to that port.
fresh-hanging-on-loop2

No Port configuration?

i have 2 project/service on the same directory (and subdirectory), one listen on 3000, and other one 8088

with https://github.com/codegangsta/gin

i can do this:

gin -i -b service1 # proxies 3000 for 3001
cd service2 && ./start2.sh

# where the content of start2.sh are something like this:
gin -i -b service2 -p 8088 -a 8089                                                                                           

is there equivalent configuration for fresh?

Bug! Should've ignored format string in logs

Minimal case,

func main () {
    log.Println ("Hello There! %Y %s", "123")
}

And you will see this in fresh,

15:24:52 app         | 2016/05/16 15:24:52 Hello There! %!Y(MISSING) %!s(MISSING) 123

Support for passing args

I'm running a martini server using fresh and I need to pass some command line args to my program, but can't find any support for it.

It would be great with either a command line switch for the fresh command:

fresh -a "--my-custom-arg=123 --and-another=true"

... or an option in the config file:

args: --my-custom-arg=123 --and-another=true

Perhaps both?

8 seconds to get reloaded~

Looks like the building process take too lone time.
Do you guy has any suggest to overcome it?

It just painful to wait 8 seconds for a change ~
I am using a gin for simple test now.

14:21:03 watcher     | sending event "./src/main.go": MODIFY|ATTRIB
14:21:03 main        | receiving first event "./src/main.go": MODIFY|ATTRIB
14:21:03 main        | sleeping for 600 milliseconds
14:21:03 watcher     | sending event "./src/main.go": MODIFY
14:21:03 main        | flushing events
14:21:03 main        | receiving event "./src/main.go": MODIFY
14:21:03 main        | Started! (23 Goroutines)
14:21:03 main        | remove tmp/runner-build-errors.log: no such file or directory
14:21:03 build       | Building...
14:21:11 runner      | Running...
14:21:11 runner      | Killing PID 200
14:21:11 main        | --------------------
14:21:11 main        | Waiting (loop 5)...
14:21:11 app         | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

14:21:11 app         | [GIN-debug] GET    /ping                     --> main.setupRouter.func1 (3 handlers)

App is not restarted on error

By the looks of it, you don't listen for signals of process you are executing after build.
If there is some error afterwards, it doesn't do anything.
Listen for signals and restart app or exit pilu/fresh on app error to allow docker container to restart itself.

It's critical if used inside docker.

'open tmp/runner-build: no such file or directory' error when rebuilding in Docker container

Hi there,

I'm using fresh on Windows 10 inside a Docker container. fresh seems to build the project correctly the first time, but on subsequent rebuilds will fail with go install github.com/me/project: open tmp/runner-build: no such file or directory. If I bash into the container I can see tmp/runner-build when listing the directory contents, but when trying to interact with it I get more no such file or directory errors. My initial thought was that this is was a permission issue but it doesn't appear to be.

Not sure if this repo is too active anymore, but has anyone encountered this before?

race detector

It could be fine to add the race detector by option (or even by default !)

Support for getgb.io

Do you have any concerns regarding putting a build command in config file?
Default config would be "go", "build"..., but it would allow us to define "gb", "build".
It is already done for "run" command with build_name.

I've seen that you're in the middle of refactoring so I am curious should I wait or create a PR anytime soon?

Logs buffered

I'm running fresh using martini and noticed that logs don't show until the project is rebuilt, how can I fix that?

Fresh does not support go mod vendor?

Fresh does not support go mod vendor?

I start a project with go mod. When I build and run my project, I can use go build -mod=vendor cmd/main.go and go run -mod=vendor cmd/main.go.

But I can not use fresh, because the source of build step in fresh is cmd := exec.Command("go", "build", "-o", buildPath(), root()).

Am I right? How can I use fresh in my project.

My project folder is :
├── cmd
│   └── main.go
├── go.mod
├── go.sum
├── internal
├── runner.conf
└── vendor

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.