Giter Club home page Giter Club logo

rizla's Introduction

Rizla builds, runs and monitors your Go Applications with ease.

Travis Widget Release Widget Report Widget License Widget Chat Widget

Installation

The only requirement is the Go Programming Language, at least 1.7.

$ go get -u github.com/kataras/rizla

Getting Started

$ rizla main.go #single project monitoring
$ rizla C:/myprojects/project1/main.go C:/myprojects/project2/main.go #multi projects monitoring
$ rizla -walk main.go #prepend '-walk' only when the default file changes scanning method doesn't works for you.
$ rizla -delay=5s main.go # if delay > 0 then it delays the reload, also note that it accepts the first change but the rest of changes every "delay".

Want to use it from your project's source code? easy

$ cat from_code_simple.go
package main

import (
    "github.com/kataras/rizla/rizla"
)

func main() {
  // Build, run & start monitoring the projects
  rizla.Run("C:/iris-project/main.go", "C:/otherproject/main.go")
  // watcher, _ := rizla.WatcherFromFlag("-walk")
  // rizla.RunWith(watcher, "./main.go", 0)
}
$ cat from_code_pro.go
package main

import (
    "path/filepath"
    "runtime"
    "time"
    "os"

    "github.com/kataras/rizla/rizla"
)

func main() {
  // Create a new project by the main source file
  project := rizla.NewProject("C:/myproject/main.go")

  // The below are optional

  // Optionally, change the out for info logs and error messages.
  project.Out.SetOutput(os.Stdout)
  project.Err.SetOutput(os.Stderr)

  project.Name = "My super project"
  // Allow reload every 3 seconds or more no less
  project.AllowReloadAfter = time.Duration(3) * time.Second
  // Custom subdirectory matcher, for the watcher, return true to include this folder to the watcher
  // the default is:
  project.Watcher = func(absolutePath string) bool {
        base := filepath.Base(abs)
        return !(base == ".git" || base == "node_modules" || base == "vendor")
  }
  // Custom file matcher on runtime (file change), return true to reload when a file with this file name changed
  // the default is:
  project.Matcher = func(filename string) bool {
        isWindows = runtime.GOOS == "windows"
        goExt     = ".go"
        return (filepath.Ext(fullname) == goExt) ||
        (!isWindows && strings.Contains(fullname, goExt))
  }
  // Add arguments, these will be used from the executable file
  project.Args = []string{"-myargument","the value","-otherargument","a value"}
  // Custom callback before reload, the default is:
  project.OnReload = func(string) {
        fromproject := ""
        if p.Name != "" {
            fromproject = "From project '" + project.Name + "': "
        }
        project.Out.Infof("%sA change has been detected, reloading now...", fromproject)
   }
   // Custom callback after reload, the default is:
   project.OnReloaded = func(string) {
        
   }

  // End of optional

  // Add the project to the rizla container
  rizla.Add(project)
  //  Build, run & start monitoring the project(s)
  rizla.Run(nil)
}

That's all!

FAQ

Ask questions and get real-time answers from the Chat.

Features

  • Super easy - is created for everyone.
  • You can use it either as command line tool either as part of your project's source code!
  • Multi-Monitoring - Supports monitoring of unlimited projects.
  • Rizla, by-default, uses the operating system's signals to fire a change because it is the fastest way and it consumes the minimal CPU.
    • You 're still able to change the watcher to use the filepath.Walk too with -walk flag.
  • delay reload on detect change with -delay

People


If you'd like to discuss this package, or ask questions about it, feel free to Chat.

The author of rizla is @kataras.

Versioning

Current: v0.1.1

HISTORY file is your best friend!

Read more about Semantic Versioning 2.0.0

Todo

  • Tests
  • Provide full examples.

Third-Party Licenses

Third-Party Licenses can be found here

License

This project is licensed under the MIT License.

License can be found here.

rizla's People

Contributors

blunt1337 avatar kataras 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

rizla's Issues

About -flag

func main() {
	host := flag.String("host", "abc.com", "domain")
	flag.Parse()
	fmt.Printf("%#v", *host)
}
`

main -host abcde.com
"abcde.com"

rizla main.go -host abcde.com
"abc.com"

what should I do?

can not directly update iris when iris has new version

[DBUG] 2017/10/01 11:59 Host: register startup notifier
[DBUG] 2017/10/01 11:59 Host: register server shutdown on interrupt(CTRL+C/CMD+C)
[DBUG] 2017/10/01 11:59 Host: server will ignore the following errors: []
Now listening on: http://localhost:8089
Application started. Press CMD+C to shut down.
[WARN] 2017/10/01 11:59 A new version is available online[8.4.4 > 8.4.3].
Release notes: https://github.com/kataras/iris/blob/master/HISTORY.md#su-01-october-2017--v844
Update now?[y/n]:
[INFO] 2017/10/01 11:59 Ignore updates? Disable version checker via:
app.Run(..., iris.WithoutVersionChecker)

Exit status 1

Hey!

I am running rizla inside code (same code as in example) and after changing file i get:

A change has been detected, reloading now...kill: exit status 1
and it's never restarted. Using Ubuntu 17.10

Any idea?

rizla run main.go works as expected

Can not find "github.com/iris-contrib/color"?

In the file "printer.go"

package rizla

import (
	"os"

	"github.com/iris-contrib/color"
	"github.com/mattn/go-colorable"
)

// Printer the printer for a rizla instance
type Printer struct {
	*color.Color
	// stream is the output stream which the program will use
	stream *os.File
}

// NewPrinter returns a new colorable printer
func NewPrinter(out *os.File) *Printer {
	c := color.New(colorable.NewColorable(out))
	return &Printer{
		Color:  c,
		stream: out,
	}
}
...

But is "github.com/fatih/color" in the file main.go.

Check it please!

question

my project have many main file , so when i run rizla main.go , err: main redeclared in this block
, how to resolve?

rizla only working 1 time?

I'm using rizla on the iris project.Here is my steps.

  1. I'm going to go\src\github.com\kataras\rizla, and build it, then I copy the main.exe to rizla project
  2. run the cmd.exe and input rizla main.go
  3. first time, it is working, it auto reload.
  4. I ctrl+c to shut down, and try to rizla main.go, it does not auto reload.

What's wrong for me?

Error 128 when editing go files

Rizla is giving me A change has been detected, reloading now...exit status 128 when I edit a .go file.

I just finished setting up Go 1.8 on Windows 10. I don't use anti-virus software.

Created hello.go file:

package main

import "fmt"

func main() {
	fmt.Println("Hello world")
}

Running rizla works:
rizla.exe src/hello/hello.go
Hello world

But when I edit hello.go it gives me this:
image

I tried running rizla with -walk, it wont detect changes.
I tried running rizla from a terminal with admin rights and got same error: "...exit status 128"

Any ideas how I could get rizla to work?

Thanks in advance!

proc.Release() cause process won't be killed

I have problem with iris run and found that the process won't be killed when code changed.

$ go version
go version go1.7 darwin/amd64

Error (code from iris create without any change)

$ rizla backend/main.go
         _____      _
        |_   _|    (_)
          | |  ____ _  ___
          | | | __|| |/ __|
         _| |_| |  | |\__ \
        |_____|_|  |_||___/ 4.1.1

Sun, 28 Aug 2016 22:37:43 GMT: Running at 127.0.0.1:8080

A change has been detected, reloading now...ready!
listen tcp4 127.0.0.1:8080: bind: address already in use
panic: listen tcp4 127.0.0.1:8080: bind: address already in use

goroutine 1 [running]:
panic(0x632200, 0xc4202aa700)
        /usr/local/Cellar/go/1.7/libexec/src/runtime/panic.go:500 +0x1a1
github.com/iris-contrib/logger.(*Logger).Panic(0xc4202aa5b0, 0x632200, 0xc4202aa700)
        /Users/acoshift/Projects/gopath/src/github.com/iris-contrib/logger/logger.go:125 +0x9e
github.com/kataras/iris.(*Framework).Must(0xc4202514a0, 0xa2ba60, 0xc4203269b0)
        /Users/acoshift/Projects/gopath/src/github.com/kataras/iris/iris.go:374 +0xa1
github.com/kataras/iris.(*Framework).Listen(0xc4202514a0, 0x71558f, 0xe)
        /Users/acoshift/Projects/gopath/src/github.com/kataras/iris/iris.go:460 +0xe9
github.com/kataras/iris.Listen(0x71558f, 0xe)
        /Users/acoshift/Projects/gopath/src/github.com/kataras/iris/iris.go:450 +0x41
main.main()
        /Users/acoshift/Projects/gopath/src/test/backend/main.go:38 +0x250

After I try remove proc.Release() from rizla.go line 261, it fix the problem.

Rizla throwing fork/exec: no such file or directory

$ rizla main.go
The above throws the following error
[ERRO] 2019/11/08 01:09 fork/exec ./cms_go: no such file or directory
and is stuck there.
When saving a file it does say change detected but that is it. Then again the same above error. Please help in how to fix this.

Thanks in advanced.

Support multiple source files for Run()

Currently when multiple source files are passed to Run(), rizla creates multiple projects. When creating a project that uses platform-specific go files, it is necessary to pass in multiple .go files to go run: http://stackoverflow.com/questions/26920969/why-does-the-go-run-command-fail-to-find-a-second-file-in-the-main-package

It would be nice to have a Project handle multiple main source files to support this.

In support of: https://github.com/kataras/iris/issues/421

How to use rizla

I import rizla to my GOPATH. When I input rizla main.go in Terminal ,it reply me bash: rizla: command not found...

Running child process has exited and the iris's reloading does not work

When I modified a go file, the iris detected it changed. But the file I modify has some syntax errors, the iris will give some build error. For example:

image

After I finished the go file, in other words it has no syntax errors, the iris detected the changes, and then it will rebuild and reload. But it gave me an error. As follows:

image

And I have looked up the error code, it stands for "No Waiting Child Process".
The problem is caused when killing a non-existent process.
I have checked the rizla code, maybe we can take this exception as a friendly one.

image

processes not been killed

OS: arch linux
go: 1.8.1

oliveag+ 12379  0.0  0.0 208760 10660 pts/7    Sl+  10:34   0:00 ./main
oliveag+ 12603  0.2  0.1 128208 12572 pts/7    Sl+  10:34   0:00 ./main
       // here. proc.Pid > 0 
	if !isMac {
		err = proc.Release()
		if err != nil {
			return nil // to prevent throw an error if the proc is not yet started correctly (= previous build error)
		}
	}
        // now proc.Pid is always -1
	if proc.Pid <= 0 {
		return nil
	}

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.