github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/client/cli/run/cli.go (about) 1 // Package runtime is the micro runtime 2 package runtime 3 4 import ( 5 "github.com/tickoalcantara12/micro/v3/cmd" 6 "github.com/urfave/cli/v2" 7 ) 8 9 // flags is shared flags so we don't have to continually re-add 10 var flags = []cli.Flag{ 11 &cli.StringFlag{ 12 Name: "name", 13 Usage: "Set the name of the service. Otherwise defaults to directory name", 14 }, 15 &cli.StringFlag{ 16 Name: "source", 17 Usage: "Set the source url of the service e.g github.com/micro/services", 18 }, 19 &cli.StringFlag{ 20 Name: "image", 21 Usage: "Set the image to use for the container", 22 }, 23 &cli.StringFlag{ 24 Name: "command", 25 Usage: "Command to exec", 26 }, 27 &cli.StringFlag{ 28 Name: "args", 29 Usage: "Command args", 30 }, 31 &cli.StringFlag{ 32 Name: "type", 33 Usage: "The type of service operate on", 34 }, 35 &cli.StringSliceFlag{ 36 Name: "env_vars", 37 Usage: "Set the environment variables e.g. foo=bar", 38 }, 39 &cli.IntFlag{ 40 Name: "instances", 41 Aliases: []string{"i"}, 42 Usage: "Number of instances to run", 43 Value: 1, 44 }, 45 &cli.StringSliceFlag{ 46 Name: "metadata", 47 Usage: "Set any metadata on the service e.g. foo=bar", 48 }, 49 &cli.BoolFlag{ 50 Name: "watch", 51 Usage: `Enable live-reloading, watch the file changes of source directories, then rebuild and restart the service. 52 only watching *.go and *.proto files now`, 53 }, 54 &cli.IntFlag{ 55 Name: "watch_delay", 56 Usage: `Watching delay milliseconds for live-reloading, only valid when --watch=true. 57 e.g. watch_delay=500 means watching delay time is 500ms.`, 58 Value: 1000, 59 }, 60 &cli.BoolFlag{ 61 Name: "force", 62 Usage: "Force rebuild and restart the service even though the service is running.", 63 }, 64 } 65 66 func init() { 67 cmd.Register( 68 &cli.Command{ 69 // In future we'll also have `micro run [x]` hence `micro run service` requiring "service" 70 Name: "run", 71 Usage: RunUsage, 72 Description: `Examples: 73 micro run github.com/micro/services/helloworld 74 micro run . # deploy local folder to your local micro server 75 micro run ../path/to/folder # deploy local folder to your local micro server 76 micro run helloworld # deploy latest version, translates to micro run github.com/micro/services/helloworld 77 micro run helloworld@9342934e6180 # deploy certain version 78 micro run helloworld@branchname # deploy certain branch`, 79 Flags: flags, 80 Action: runService, 81 }, 82 &cli.Command{ 83 Name: "update", 84 Usage: UpdateUsage, 85 Description: `Examples: 86 micro update github.com/micro/services/helloworld 87 micro update . # deploy local folder to your local micro server 88 micro update ../path/to/folder # deploy local folder to your local micro server 89 micro update helloworld # deploy master branch, translates to micro update github.com/micro/services/helloworld 90 micro update helloworld@branchname # deploy certain branch`, 91 Flags: flags, 92 Action: updateService, 93 }, 94 &cli.Command{ 95 Name: "kill", 96 Usage: KillUsage, 97 Flags: flags, 98 Description: `Examples: 99 micro kill github.com/micro/services/helloworld 100 micro kill . # kill service deployed from local folder 101 micro kill ../path/to/folder # kill service deployed from local folder 102 micro kill helloworld # kill serviced deployed from master branch, translates to micro kill github.com/micro/services/helloworld 103 micro kill helloworld@branchname # kill service deployed from certain branch`, 104 Action: killService, 105 }, 106 &cli.Command{ 107 Name: "status", 108 Usage: GetUsage, 109 Flags: flags, 110 Action: getService, 111 }, 112 &cli.Command{ 113 Name: "logs", 114 Usage: "Get logs for a service e.g. micro logs helloworld", 115 Action: getLogs, 116 Flags: []cli.Flag{ 117 &cli.StringFlag{ 118 Name: "version", 119 Usage: "Set the version of the service to debug", 120 }, 121 &cli.StringFlag{ 122 Name: "output", 123 Aliases: []string{"o"}, 124 Usage: "Set the output format e.g json, text", 125 }, 126 &cli.BoolFlag{ 127 Name: "follow", 128 Aliases: []string{"f"}, 129 Usage: "Set to stream logs continuously", 130 }, 131 &cli.StringFlag{ 132 Name: "since", 133 Usage: "Set to the relative time from which to show the logs for e.g. 1h", 134 }, 135 &cli.IntFlag{ 136 Name: "lines", 137 Aliases: []string{"n"}, 138 Usage: "Set to query the last number of log events", 139 }, 140 }, 141 }, 142 ) 143 }