Make sure the WorkQueue terminates when running command line tools
If we don't call WorkQueue.terminate() the thread pool will stay running, pegging the JVM open until the user hits Contrl-C in the tty to break it out. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.pgm;
|
package com.google.gerrit.pgm;
|
||||||
|
|
||||||
import com.google.gerrit.client.rpc.Common;
|
import com.google.gerrit.client.rpc.Common;
|
||||||
|
import com.google.gerrit.git.WorkQueue;
|
||||||
import com.google.gerrit.server.GerritServer;
|
import com.google.gerrit.server.GerritServer;
|
||||||
import com.google.gwtjsonrpc.server.XsrfException;
|
import com.google.gwtjsonrpc.server.XsrfException;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
@@ -25,6 +26,15 @@ import com.google.gwtorm.client.OrmException;
|
|||||||
public class CreateSchema {
|
public class CreateSchema {
|
||||||
public static void main(final String[] argv) throws OrmException,
|
public static void main(final String[] argv) throws OrmException,
|
||||||
XsrfException {
|
XsrfException {
|
||||||
|
try {
|
||||||
|
mainImpl(argv);
|
||||||
|
} finally {
|
||||||
|
WorkQueue.terminate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mainImpl(final String[] argv) throws OrmException,
|
||||||
|
XsrfException {
|
||||||
GerritServer.getInstance();
|
GerritServer.getInstance();
|
||||||
Common.getSchemaFactory().open().close();
|
Common.getSchemaFactory().open().close();
|
||||||
System.out.println("Gerrit2 schema initialized");
|
System.out.println("Gerrit2 schema initialized");
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.google.gerrit.client.reviewdb.SystemConfig;
|
|||||||
import com.google.gerrit.client.rpc.Common;
|
import com.google.gerrit.client.rpc.Common;
|
||||||
import com.google.gerrit.git.InvalidRepositoryException;
|
import com.google.gerrit.git.InvalidRepositoryException;
|
||||||
import com.google.gerrit.git.PatchSetImporter;
|
import com.google.gerrit.git.PatchSetImporter;
|
||||||
|
import com.google.gerrit.git.WorkQueue;
|
||||||
import com.google.gerrit.server.ChangeUtil;
|
import com.google.gerrit.server.ChangeUtil;
|
||||||
import com.google.gerrit.server.GerritServer;
|
import com.google.gerrit.server.GerritServer;
|
||||||
import com.google.gwtjsonrpc.server.XsrfException;
|
import com.google.gwtjsonrpc.server.XsrfException;
|
||||||
@@ -79,7 +80,16 @@ public class ImportGerrit1 {
|
|||||||
private static ApprovalCategory submitCategory;
|
private static ApprovalCategory submitCategory;
|
||||||
|
|
||||||
public static void main(final String[] argv) throws OrmException,
|
public static void main(final String[] argv) throws OrmException,
|
||||||
XsrfException, SQLException, IOException, InvalidRepositoryException {
|
XsrfException, IOException, SQLException, InvalidRepositoryException {
|
||||||
|
try {
|
||||||
|
mainImpl(argv);
|
||||||
|
} finally {
|
||||||
|
WorkQueue.terminate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mainImpl(final String[] argv) throws OrmException,
|
||||||
|
XsrfException, IOException, SQLException, InvalidRepositoryException {
|
||||||
final ProgressMonitor pm = new TextProgressMonitor();
|
final ProgressMonitor pm = new TextProgressMonitor();
|
||||||
gs = GerritServer.getInstance();
|
gs = GerritServer.getInstance();
|
||||||
db = Common.getSchemaFactory().open();
|
db = Common.getSchemaFactory().open();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.google.gerrit.client.reviewdb.ReviewDb;
|
|||||||
import com.google.gerrit.client.rpc.Common;
|
import com.google.gerrit.client.rpc.Common;
|
||||||
import com.google.gerrit.git.InvalidRepositoryException;
|
import com.google.gerrit.git.InvalidRepositoryException;
|
||||||
import com.google.gerrit.git.PatchSetImporter;
|
import com.google.gerrit.git.PatchSetImporter;
|
||||||
|
import com.google.gerrit.git.WorkQueue;
|
||||||
import com.google.gerrit.server.GerritServer;
|
import com.google.gerrit.server.GerritServer;
|
||||||
import com.google.gwtjsonrpc.server.XsrfException;
|
import com.google.gwtjsonrpc.server.XsrfException;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
@@ -54,6 +55,15 @@ import java.util.ArrayList;
|
|||||||
public class ReimportPatchSets {
|
public class ReimportPatchSets {
|
||||||
public static void main(final String[] argv) throws OrmException,
|
public static void main(final String[] argv) throws OrmException,
|
||||||
XsrfException, IOException {
|
XsrfException, IOException {
|
||||||
|
try {
|
||||||
|
mainImpl(argv);
|
||||||
|
} finally {
|
||||||
|
WorkQueue.terminate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mainImpl(final String[] argv) throws OrmException,
|
||||||
|
XsrfException, IOException {
|
||||||
final GerritServer gs = GerritServer.getInstance();
|
final GerritServer gs = GerritServer.getInstance();
|
||||||
final ArrayList<PatchSet.Id> todo = new ArrayList<PatchSet.Id>();
|
final ArrayList<PatchSet.Id> todo = new ArrayList<PatchSet.Id>();
|
||||||
final BufferedReader br =
|
final BufferedReader br =
|
||||||
|
|||||||
Reference in New Issue
Block a user