Commit 4f1d2a10 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

page-server: allow to execute page-server in the background (v2)

page-server creates a listen socket and only then goes into the
background, so we can be sure, that page-server is ready for work after
detaching.

v2: call daemon() in a proper place and reuse the option -d
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e8e1cae2
......@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
}
if (!strcmp(argv[optind], "page-server"))
return cr_page_server();
return cr_page_server(opts.restore_detach);
pr_msg("Unknown command \"%s\"\n", argv[optind]);
usage:
......@@ -415,6 +415,7 @@ usage:
"Page server options\n"
" --address ADDR address of page server\n"
" --port PORT port of page server\n"
" -d run in the background after creating socket\n"
"\n"
"Show options:\n"
" -f|--file FILE show contents of a checkpoint file\n"
......
#ifndef __CR_PAGE_XFER__H__
#define __CR_PAGE_XFER__H__
int cr_page_server(void);
int cr_page_server(bool daemon_mode);
/*
* page_xfer -- transfer pages into image file.
......
......@@ -195,7 +195,7 @@ static int page_server_serve(int sk)
return ret;
}
int cr_page_server(void)
int cr_page_server(bool daemon_mode)
{
int sk, ask = -1;
struct sockaddr_in caddr;
......@@ -223,6 +223,9 @@ int cr_page_server(void)
goto out;
}
if (daemon_mode)
daemon(0, 0);
ask = accept(sk, (struct sockaddr *)&caddr, &clen);
if (ask < 0)
pr_perror("Can't accept connection to server");
......
......@@ -350,7 +350,7 @@ EOF
mkdir -p $ddump
if [ $PAGE_SERVER -eq 1 ]; then
$CRTOOLS page-server -D $ddump -o page_server.log -v 4 --port $PS_PORT &
$CRTOOLS page-server -D $ddump -o page_server.log -v 4 --port $PS_PORT -d
PS_PID=$!
opts="--page-server --address 127.0.0.1 --port $PS_PORT"
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment