package nl.jpoint.vertx.mod.cluster.command;

import nl.jpoint.vertx.mod.cluster.request.ModuleRequest;
import nl.jpoint.vertx.mod.cluster.util.LogConstants;
import nl.jpoint.vertx.mod.cluster.util.ModuleFileNameFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vertx.java.core.Vertx;
import org.vertx.java.core.json.JsonObject;

import java.io.File;
import java.io.IOException;

public class UndeployModule implements Command {

    private static final Logger LOG = LoggerFactory.getLogger(UndeployModule.class);
    private static final String PID_DIR = "/var/run/edubase/";
    private final Vertx vertx;
    private final File modRoot;

    public UndeployModule(Vertx vertx, File modRoot) {
        this.vertx = vertx;
        this.modRoot = modRoot;
    }

    @Override
    public JsonObject execute(ModuleRequest request) {
        Process killProcess = null;

        for (String file : modRoot.list(new ModuleFileNameFilter(request))) {
            LOG.info("[{} - {}]: Stopping module {}", LogConstants.DEPLOY_REQUEST, request.getId(),file);

            try {
                killProcess = Runtime.getRuntime().exec(new String[]{"/etc/init.d/vertx", "stop", request.getModuleId()});
                killProcess.waitFor();
            } catch (IOException | InterruptedException e) {
                LOG.error("[{} - {}]: Failed to initialize module {}", LogConstants.DEPLOY_REQUEST, request.getId(), request.getModuleId());
                return null;
            }

            vertx.fileSystem().deleteSync(modRoot+"/"+file, true);
            LOG.info("[{} - {}]: Undeployed old module : {}", LogConstants.DEPLOY_REQUEST, request.getId(), file);
        }
        return null;
    }
}

@@ -1190,37 +1190,20 @@
 %22stop%22, 
-request.getModuleId()
+file
 %7D);%0A    
@@ -1350,18 +1350,12 @@
  to 
-initialize
+stop
  mod

Use correct module name to stop for undeploying