mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 01:52:34 +00:00
Make possible to daemonize lxc-start
If needed the container can be launched in background with a specific option -d. That will make mute the container, the logs can help to check what went wrong. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
f8e09a0b76
commit
c36583c303
@ -74,6 +74,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
|
||||||
|
<title>Options</title>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>-d, --daemon</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Run the container as a daemon. As the container has no
|
||||||
|
more tty, if an error occurs nothing will be displayed,
|
||||||
|
the log file can be used to check the error.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
&commonoptions;
|
&commonoptions;
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
@ -102,7 +125,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
@ -42,6 +42,7 @@ struct lxc_arguments {
|
|||||||
char *log_file;
|
char *log_file;
|
||||||
char *log_priority;
|
char *log_priority;
|
||||||
int quiet;
|
int quiet;
|
||||||
|
int daemonize;
|
||||||
const char *rcfile;
|
const char *rcfile;
|
||||||
const char *statefile;
|
const char *statefile;
|
||||||
|
|
||||||
|
@ -26,11 +26,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
@ -41,7 +43,16 @@
|
|||||||
|
|
||||||
lxc_log_define(lxc_start, lxc);
|
lxc_log_define(lxc_start, lxc);
|
||||||
|
|
||||||
|
static int my_parser(struct lxc_arguments* args, int c, char* arg)
|
||||||
|
{
|
||||||
|
switch (c) {
|
||||||
|
case 'd': args->daemonize = 1; break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct option my_longopts[] = {
|
static const struct option my_longopts[] = {
|
||||||
|
{"daemon", no_argument, 0, 'd'},
|
||||||
LXC_COMMON_OPTIONS
|
LXC_COMMON_OPTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,10 +64,12 @@ static struct lxc_arguments my_args = {
|
|||||||
lxc-start start COMMAND in specified container NAME\n\
|
lxc-start start COMMAND in specified container NAME\n\
|
||||||
\n\
|
\n\
|
||||||
Options :\n\
|
Options :\n\
|
||||||
-n, --name=NAME NAME for name of the container",
|
-n, --name=NAME NAME for name of the container\n\
|
||||||
|
-d, --daemon daemonize the container",
|
||||||
.options = my_longopts,
|
.options = my_longopts,
|
||||||
.parser = NULL,
|
.parser = my_parser,
|
||||||
.checker = NULL,
|
.checker = NULL,
|
||||||
|
.daemonize = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int save_tty(struct termios *tios)
|
static int save_tty(struct termios *tios)
|
||||||
@ -122,6 +135,11 @@ int main(int argc, char *argv[])
|
|||||||
my_args.progname, my_args.quiet))
|
my_args.progname, my_args.quiet))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
if (my_args.daemonize && daemon(0 ,0)) {
|
||||||
|
SYSERROR("failed to daemonize '%s'", my_args.name);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
save_tty(&tios);
|
save_tty(&tios);
|
||||||
|
|
||||||
err = lxc_start(my_args.name, args);
|
err = lxc_start(my_args.name, args);
|
||||||
|
Loading…
Reference in New Issue
Block a user