Gitlab Community Edition Instance

Commit f0c8fdab authored by mhellka's avatar mhellka
Browse files

Make pidfile optional

parent bc1ecc39
......@@ -139,7 +139,7 @@ public class CDStarRuntime implements RuntimeContext, Closeable {
config.setDefault("path.var", "${path.home}/var");
config.setDefault("http.host", "${CDSTAR_HOST:127.0.0.1}");
config.setDefault("http.port", "${CDSTAR_PORT:8080}");
config.setDefault("pidfile", "${path.var}/cdstar.pid"); // Undocumented
// config.setDefault("pidfile", "${path.var}/cdstar.pid"); // Undocumented
config = new WildcardConfig(new LoggingConfig(config));
// Resolve paths (all paths are relative to path.home, not the current
......@@ -147,10 +147,10 @@ public class CDStarRuntime implements RuntimeContext, Closeable {
homePath = Paths.get(config.get("path.home")).toAbsolutePath();
dataPath = homePath.resolve(config.get("path.data")).toAbsolutePath();
varPath = homePath.resolve(config.get("path.var")).toAbsolutePath();
libPaths = config.getList("path.lib").stream()
.map(s -> homePath.resolve(s).toAbsolutePath())
.collect(Collectors.toList());
pidfile = new PidFileLock(homePath.resolve(config.get("pidfile")));
libPaths = config.getList("path.lib").stream().map(s -> homePath.resolve(s).toAbsolutePath())
.collect(Collectors.toList());
pidfile = config.hasKey("pidfile") ? new PidFileLock(homePath.resolve(config.get("pidfile"))) : null;
services = new ServiceRegistry();
authConfig = new AuthConfigImpl();
......@@ -175,7 +175,8 @@ public class CDStarRuntime implements RuntimeContext, Closeable {
log.info(" path.data: {}", dataPath);
log.info(" path.var: {}", varPath);
log.info(" path.lib: {}", Utils.join(", ", libPaths));
log.info(" pidfile: {}", pidfile.getPath());
if (pidfile != null)
log.info(" pidfile: {}", pidfile.getPath());
log.debug("Installing core services...");
......@@ -266,15 +267,17 @@ public class CDStarRuntime implements RuntimeContext, Closeable {
ensureDirectoryExistsAndIsWriteable(dataPath);
ensureDirectoryExistsAndIsWriteable(varPath);
try {
pidfile.create();
} catch (final IOException e) {
if (e instanceof FileAlreadyExistsException) {
log.error("Pidfile already exists. This may be caused by an unclean shutdown. "
+ "Make sure no other instance of CDSTAR is running, then remove the pidfile manually: {}",
pidfile.getPath());
if (pidfile != null) {
try {
pidfile.create();
} catch (final IOException e) {
if (e instanceof FileAlreadyExistsException) {
log.error("Pidfile already exists. This may be caused by an unclean shutdown. "
+ "Make sure no other instance of CDSTAR is running, then remove the pidfile manually: {}",
pidfile.getPath());
}
throw new IOException("Failed to create pidfile: " + pidfile.getPath(), e);
}
throw new IOException("Failed to create pidfile: " + pidfile.getPath(), e);
}
for (final RuntimeListener rl : lookupAll(RuntimeListener.class))
......@@ -320,7 +323,7 @@ public class CDStarRuntime implements RuntimeContext, Closeable {
}
startedRuntimeListeners.clear();
if (pidfile.isLocked()) {
if (pidfile != null && pidfile.isLocked()) {
try {
pidfile.remove();
} catch (final IOException e) {
......
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