Browse Source

Merge "docker: don't daemonize when starting images"

tags/3.5.0
Zuul 2 months ago
parent
commit
95f7071c2a
4 changed files with 28 additions and 19 deletions
  1. 2
    2
      Dockerfile
  2. 20
    9
      nodepool/cmd/__init__.py
  3. 3
    4
      nodepool/cmd/builder.py
  4. 3
    4
      nodepool/cmd/launcher.py

+ 2
- 2
Dockerfile View File

@@ -25,7 +25,7 @@ RUN /output/install-from-bindep
25 25
 CMD ["/usr/local/bin/nodepool"]
26 26
 
27 27
 FROM nodepool as nodepool-launcher
28
-CMD ["/usr/local/bin/nodepool-launcher"]
28
+CMD ["/usr/local/bin/nodepool-launcher", "-f"]
29 29
 
30 30
 FROM nodepool as nodepool-builder
31
-CMD ["/usr/local/bin/nodepool-builder"]
31
+CMD ["/usr/local/bin/nodepool-builder", "-f"]

+ 20
- 9
nodepool/cmd/__init__.py View File

@@ -106,9 +106,16 @@ class NodepoolApp(object):
106 106
         return parser
107 107
 
108 108
     def parse_args(self):
109
-        args = self.parser.parse_args()
110
-        self.logconfig = self.get_path(args.logconfig)
111
-        return args
109
+        self.args = self.parser.parse_args()
110
+        self.logconfig = self.get_path(self.args.logconfig)
111
+
112
+        # The arguments debug and foreground both lead to nodaemon mode so
113
+        # set nodaemon if one of them is set.
114
+        if ((hasattr(self.args, 'debug') and self.args.debug) or
115
+                (hasattr(self.args, 'foreground') and self.args.foreground)):
116
+            self.args.nodaemon = True
117
+        else:
118
+            self.args.nodaemon = False
112 119
 
113 120
     def setup_logging(self):
114 121
         if self.logconfig:
@@ -118,7 +125,8 @@ class NodepoolApp(object):
118 125
             # config, leave the config set to emit to stdout.
119 126
             if hasattr(self.args, 'nodaemon') and self.args.nodaemon:
120 127
                 logging_config = logconfig.ServerLoggingConfig()
121
-                logging_config.setDebug()
128
+                if hasattr(self.args, 'debug') and self.args.debug:
129
+                    logging_config.setDebug()
122 130
             else:
123 131
                 # Setting a server value updates the defaults to use
124 132
                 # WatchedFileHandler on /var/log/nodepool/{server}-debug.log
@@ -132,7 +140,7 @@ class NodepoolApp(object):
132 140
             argv = sys.argv[1:]
133 141
 
134 142
         self.parser = self.create_parser()
135
-        self.args = self.parse_args()
143
+        self.parse_args()
136 144
         return self._do_run()
137 145
 
138 146
     def _do_run(self):
@@ -161,16 +169,19 @@ class NodepoolDaemonApp(NodepoolApp):
161 169
                             default='/var/run/nodepool/%s.pid' % self.app_name)
162 170
 
163 171
         parser.add_argument('-d',
164
-                            dest='nodaemon',
172
+                            dest='debug',
173
+                            action='store_true',
174
+                            help='do not run as a daemon with debug logging')
175
+        parser.add_argument('-f',
176
+                            dest='foreground',
165 177
                             action='store_true',
166 178
                             help='do not run as a daemon')
167 179
 
168 180
         return parser
169 181
 
170 182
     def parse_args(self):
171
-        args = super(NodepoolDaemonApp, self).parse_args()
172
-        self.pidfile = self.get_path(args.pidfile)
173
-        return args
183
+        super().parse_args()
184
+        self.pidfile = self.get_path(self.args.pidfile)
174 185
 
175 186
     def _do_run(self):
176 187
         if self.args.nodaemon:

+ 3
- 4
nodepool/cmd/builder.py View File

@@ -48,10 +48,9 @@ class NodePoolBuilderApp(nodepool.cmd.NodepoolDaemonApp):
48 48
         return parser
49 49
 
50 50
     def parse_args(self):
51
-        args = super(NodePoolBuilderApp, self).parse_args()
52
-        self.config_file = self.get_path(args.config)
53
-        self.secure_file = self.get_path(args.secure)
54
-        return args
51
+        super(NodePoolBuilderApp, self).parse_args()
52
+        self.config_file = self.get_path(self.args.config)
53
+        self.secure_file = self.get_path(self.args.secure)
55 54
 
56 55
     def run(self):
57 56
         self.nb = builder.NodePoolBuilder(

+ 3
- 4
nodepool/cmd/launcher.py View File

@@ -42,10 +42,9 @@ class NodePoolLauncherApp(nodepool.cmd.NodepoolDaemonApp):
42 42
         return parser
43 43
 
44 44
     def parse_args(self):
45
-        args = super(NodePoolLauncherApp, self).parse_args()
46
-        self.config_file = self.get_path(args.config)
47
-        self.secure_file = self.get_path(args.secure)
48
-        return args
45
+        super().parse_args()
46
+        self.config_file = self.get_path(self.args.config)
47
+        self.secure_file = self.get_path(self.args.secure)
49 48
 
50 49
     def exit_handler(self, signum, frame):
51 50
         self.pool.stop()

Loading…
Cancel
Save