@@ -7,7 +7,6 @@ package commands
7
7
import (
8
8
"fmt"
9
9
"os"
10
- "time"
11
10
12
11
log "github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
13
12
@@ -76,21 +75,21 @@ func runRun(cmd *types.Command, args []string) {
76
75
}
77
76
78
77
// create IMAGE
79
- log .Debugf ( "Creating a new server " )
78
+ log .Info ( "Server creation ... " )
80
79
dynamicIPRequired := runGateway == ""
81
80
serverID , err := api .CreateServer (cmd .API , args [0 ], runCreateName , runCreateBootscript , runCreateEnv , runCreateVolume , dynamicIPRequired )
82
81
if err != nil {
83
82
log .Fatalf ("Failed to create server: %v" , err )
84
83
}
85
- log .Debugf ( "Created server : %s" , serverID )
84
+ log .Infof ( "Server created : %s" , serverID )
86
85
87
86
// start SERVER
88
- log .Debugf ( "Starting server " )
87
+ log .Info ( "Server start requested ... " )
89
88
err = api .StartServer (cmd .API , serverID , false )
90
89
if err != nil {
91
90
log .Fatalf ("Failed to start server %s: %v" , serverID , err )
92
91
}
93
- log .Debugf ("Server is booting " )
92
+ log .Info ("Server is starting, this may take up to a minute ... " )
94
93
95
94
if runDetachFlag {
96
95
fmt .Println (serverID )
@@ -99,7 +98,7 @@ func runRun(cmd *types.Command, args []string) {
99
98
100
99
if runAttachFlag {
101
100
// Attach to server serial
102
- log .Debugf ("Attaching to server console" )
101
+ log .Info ("Attaching to server console ... " )
103
102
err = utils .AttachToSerial (serverID , cmd .API .Token , true )
104
103
if err != nil {
105
104
log .Fatalf ("Cannot attach to server serial: %v" , err )
@@ -112,26 +111,27 @@ func runRun(cmd *types.Command, args []string) {
112
111
}
113
112
114
113
// waiting for server to be ready
115
- log .Debugf ("Waiting for server to be ready" )
114
+ log .Debug ("Waiting for server to be ready" )
116
115
// We wait for 30 seconds, which is the minimal amount of time needed by a server to boot
117
- time .Sleep (30 * time .Second )
118
116
server , err := api .WaitForServerReady (cmd .API , serverID , gateway )
119
117
if err != nil {
120
118
log .Fatalf ("Cannot get access to server %s: %v" , serverID , err )
121
119
}
122
- log .Debugf ("Server is ready: %s" , server .PublicAddress .IP )
120
+ log .Debugf ("SSH server is available: %s:22" , server .PublicAddress .IP )
121
+ log .Info ("Server is ready !" )
123
122
124
123
// exec -w SERVER COMMAND ARGS...
125
- log .Debugf ("Executing command" )
126
124
if len (args ) < 2 {
125
+ log .Info ("Connecting to server ..." )
127
126
err = utils .SSHExec (server .PublicAddress .IP , server .PrivateIP , []string {}, false , gateway )
128
127
} else {
128
+ log .Infof ("Executing command: %s ..." , args [1 :])
129
129
err = utils .SSHExec (server .PublicAddress .IP , server .PrivateIP , args [1 :], false , gateway )
130
130
}
131
131
if err != nil {
132
- log .Debugf ("Command execution failed: %v" , err )
132
+ log .Infof ("Command execution failed: %v" , err )
133
133
os .Exit (1 )
134
134
}
135
- log .Debugf ("Command successfuly executed" )
135
+ log .Info ("Command successfuly executed" )
136
136
}
137
137
}
0 commit comments