MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / rdbLoadS3

Function rdbLoadS3

src/rdb-s3.cpp:74–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int rdbLoadS3(char *s3bucket, rdbSaveInfo *rsi, int rdbflags)
75{
76 int status = EXIT_FAILURE;
77 int fd[2];
78 if (pipe(fd) != 0)
79 return C_ERR;
80
81 pid_t pid = fork();
82 if (pid < 0)
83 {
84 close(fd[0]);
85 close(fd[1]);
86 return C_ERR;
87 }
88
89 if (pid == 0)
90 {
91 // child process
92 dup2(fd[1], STDOUT_FILENO);
93 close(fd[1]);
94 close(fd[0]);
95 execlp("aws", "aws", "s3", "cp", s3bucket, "-", nullptr);
96 exit(EXIT_FAILURE);
97 }
98 else
99 {
100 close(fd[1]);
101 if (rdbLoadS3Core(fd[0], rsi, rdbflags) != C_OK)
102 {
103 close(fd[0]);
104 return C_ERR;
105 }
106 close(fd[0]);
107 waitpid(pid, &status, 0);
108 }
109
110 if (status != EXIT_SUCCESS)
111 serverLog(LL_WARNING, "Failed to load DB from AWS S3");
112 else
113 serverLog(LL_NOTICE,"DB loaded from AWS S3");
114
115 return (status == EXIT_SUCCESS) ? C_OK : C_ERR;
116}

Callers 1

rdbLoadFunction · 0.85

Calls 2

rdbLoadS3CoreFunction · 0.85
serverLogFunction · 0.85

Tested by

no test coverage detected