Skip to content

Commit

Permalink
使用makefile构建应用
Browse files Browse the repository at this point in the history
  • Loading branch information
ouqiang committed Feb 4, 2018
1 parent e1fa3cf commit 738b168
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 276 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ data
conf
profile/*
public/resource/javascript/vue.js
gocron
/gocron
gocron.exe
gocron-node
/gocron-node
gocron-node.exe
/bin
/packages

node_modules
package.json
114 changes: 0 additions & 114 deletions build.sh

This file was deleted.

93 changes: 0 additions & 93 deletions build_node.sh

This file was deleted.

61 changes: 40 additions & 21 deletions cmd/web.go → cmd/gocron/gocron.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package cmd
// main gocron

package main

import (
"os"
Expand All @@ -15,30 +17,47 @@ import (
"gopkg.in/macaron.v1"
)

var AppVersion = "1.4"

// web服务器默认端口
const DefaultPort = 5920

var CmdWeb = cli.Command{
Name: "web",
Usage: "run web server",
Action: runWeb,
Flags: []cli.Flag{
cli.StringFlag{
Name: "host",
Value: "0.0.0.0",
Usage: "bind host",
},
cli.IntFlag{
Name: "port,p",
Value: DefaultPort,
Usage: "bind port",
},
cli.StringFlag{
Name: "env,e",
Value: "prod",
Usage: "runtime environment, dev|test|prod",
func main() {
cliApp := cli.NewApp()
cliApp.Name = "gocron"
cliApp.Usage = "gocron service"
cliApp.Version = AppVersion
cliApp.Commands = getCommands()
cliApp.Flags = append(cliApp.Flags, []cli.Flag{}...)
cliApp.Run(os.Args)
}

// getCommands
func getCommands() []cli.Command {
command := cli.Command{
Name: "web",
Usage: "run web server",
Action: runWeb,
Flags: []cli.Flag{
cli.StringFlag{
Name: "host",
Value: "0.0.0.0",
Usage: "bind host",
},
cli.IntFlag{
Name: "port,p",
Value: DefaultPort,
Usage: "bind port",
},
cli.StringFlag{
Name: "env,e",
Value: "prod",
Usage: "runtime environment, dev|test|prod",
},
},
},
}

return []cli.Command{command}
}

func runWeb(ctx *cli.Context) {
Expand Down
12 changes: 6 additions & 6 deletions gocron-node.go → cmd/node/node.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// +build node
// 任务节点
// main gocron-node

package main

import (
"flag"
"fmt"
"github.com/ouqiang/gocron/modules/rpc/auth"
"github.com/ouqiang/gocron/modules/rpc/server"
"github.com/ouqiang/gocron/modules/utils"
"os"
"runtime"
"strings"

"github.com/ouqiang/gocron/modules/rpc/auth"
"github.com/ouqiang/gocron/modules/rpc/server"
"github.com/ouqiang/gocron/modules/utils"
)

const AppVersion = "1.3"
var AppVersion = "1.4"

func main() {
var serverAddr string
Expand Down
25 changes: 0 additions & 25 deletions gocron.go

This file was deleted.

18 changes: 18 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

all: build

build: gocron node

gocron:

go build -o bin/gocron ./cmd/gocron


node:

go build -o bin/gocron-node ./cmd/node

clean:

rm bin/gocron
rm bin/gocron-node
Loading

0 comments on commit 738b168

Please sign in to comment.