aboutsummaryrefslogtreecommitdiff
path: root/src/zen/cmds/up_cmd.h
blob: bcc7d7da4f0745202d47b09475c1fd830fcb334a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "../zen.h"

#include <zenutil/zenserverprocess.h>

#include <filesystem>

namespace zen {

class UpCommand : public ZenCmdBase
{
public:
	static constexpr char Name[]		= "up";
	static constexpr char Description[] = "Bring zen server up";

	UpCommand();
	~UpCommand();

	virtual void			  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options	  m_Options{Name, Description};
	uint16_t			  m_Port		= 0;
	bool				  m_ShowConsole = false;
	bool				  m_ShowLog		= false;
	std::filesystem::path m_ProgramBaseDir;
};

class AttachCommand : public ZenCmdBase
{
public:
	static constexpr char Name[]		= "attach";
	static constexpr char Description[] = "Add a sponsor process to a running zen service";

	AttachCommand();
	~AttachCommand();

	virtual void			  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options	  m_Options{Name, Description};
	uint16_t			  m_Port	 = 0;
	int					  m_OwnerPid = 0;
	std::filesystem::path m_DataDir;
};

class DownCommand : public ZenCmdBase
{
public:
	static constexpr char Name[]		= "down";
	static constexpr char Description[] = "Bring zen server down";

	DownCommand();
	~DownCommand();

	virtual void			  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options	  m_Options{Name, Description};
	uint16_t			  m_Port		   = 0;
	uint32_t			  m_Pid			   = 0;
	bool				  m_All			   = false;
	bool				  m_ForceTerminate = false;
	std::filesystem::path m_ProgramBaseDir;
	std::filesystem::path m_DataDir;
	std::filesystem::path m_ExecutablePath;
};

}  // namespace zen