package xyz.wbsite.module.conf.ent;


import xyz.wbsite.frame.utils.ProcessUtil;

import java.io.File;

public class NginxCtrl {

    private String startCmd = "start nginx";
    private String stopCmd = "nginx.exe -s quit";
    private String reloadCmd = "nginx.exe -s reload";
    private String versionCmd = "nginx -v";
    private File config = null;

    public void doStart() {
        ProcessUtil.exec(startCmd);
    }

    public void doStop() {
        ProcessUtil.exec(stopCmd);
    }

    public void doReload() {
        ProcessUtil.exec(reloadCmd);
    }

    public String getStartCmd() {
        return startCmd;
    }

    public void setStartCmd(String startCmd) {
        this.startCmd = startCmd;
    }

    public String getStopCmd() {
        return stopCmd;
    }

    public void setStopCmd(String stopCmd) {
        this.stopCmd = stopCmd;
    }

    public String getReloadCmd() {
        return reloadCmd;
    }

    public void setReloadCmd(String reloadCmd) {
        this.reloadCmd = reloadCmd;
    }

    public String getVersionCmd() {
        return versionCmd;
    }

    public void setVersionCmd(String versionCmd) {
        this.versionCmd = versionCmd;
    }

    public File getConfig() {
        return config;
    }

    public void setConfig(File config) {
        this.config = config;
    }

    public boolean isRunning() {
        return ProcessUtil.findProcess("nginx.exe");
    }
}
