Skip to content

Commit f9d4f56

Browse files
committed
Syncing cache to disk after server creation when running in a non-detached mode
1 parent 5f5c350 commit f9d4f56

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
10881088

10891089
#### Features
10901090

1091+
* Syncing cache to disk after server creation when running `scw run` in a non-detached mode
10911092
* Bump to Golang 1.5
10921093
* Support --tmp-ssh-key `scw {run,create}` option ([#99](https://github.com/scaleway/scaleway-cli/issues/99))
10931094
* Support -f `scw run --rm` option ([#117](https://github.com/scaleway/scaleway-cli/issues/117))

pkg/api/cache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"sync"
1616

1717
"github.com/scaleway/scaleway-cli/vendor/code.google.com/p/go-uuid/uuid"
18+
"github.com/scaleway/scaleway-cli/vendor/github.com/Sirupsen/logrus"
1819
"github.com/scaleway/scaleway-cli/vendor/github.com/renstrom/fuzzysearch/fuzzy"
1920
)
2021

@@ -177,6 +178,8 @@ func (c *ScalewayCache) Save() error {
177178
c.Lock.Lock()
178179
defer c.Lock.Unlock()
179180

181+
logrus.Debugf("Writing cache file to disk")
182+
180183
if c.Modified {
181184
file, err := ioutil.TempFile("", "")
182185
if err != nil {

pkg/commands/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ func Run(ctx CommandContext, args RunArgs) error {
103103
if args.Detach {
104104
fmt.Fprintln(ctx.Stdout, serverID)
105105
return nil
106+
} else {
107+
// Sync cache on disk
108+
ctx.API.Sync()
106109
}
107110

108111
if args.Attach {

0 commit comments

Comments
 (0)