summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-04-05 22:51:09 +0800
committerruki <[email protected]>2022-04-05 22:51:09 +0800
commit5ec3a71b945421da1e6a0df7b371990952cc6ead (patch)
treee7daad0c12e34521574207004dd5f2a72ed6e04a
parent850656df9fd322bb91d62be0e5d64d8f219559f8 (diff)
add some service actions
-rw-r--r--xmake/modules/private/service/connect_service.lua28
-rw-r--r--xmake/modules/private/service/disconnect_service.lua28
-rw-r--r--xmake/modules/private/service/import_config.lua28
-rw-r--r--xmake/modules/private/service/reconnect_service.lua28
-rw-r--r--xmake/modules/private/service/remote_build_server.lua (renamed from xmake/modules/private/service/remote_build_server/main.lua)2
-rw-r--r--xmake/modules/private/service/restart_service.lua30
-rw-r--r--xmake/modules/private/service/service.lua (renamed from xmake/plugins/service/service.lua)0
-rw-r--r--xmake/modules/private/service/show_logs.lua27
-rw-r--r--xmake/modules/private/service/show_status.lua27
-rw-r--r--xmake/modules/private/service/start_service.lua33
-rw-r--r--xmake/modules/private/service/stop_service.lua28
-rw-r--r--xmake/plugins/service/main.lua48
-rw-r--r--xmake/plugins/service/xmake.lua16
13 files changed, 293 insertions, 30 deletions
diff --git a/xmake/modules/private/service/connect_service.lua b/xmake/modules/private/service/connect_service.lua
new file mode 100644
index 000000000..fc427d445
--- /dev/null
+++ b/xmake/modules/private/service/connect_service.lua
@@ -0,0 +1,28 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file connect_service.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main()
+ -- TODO
+end
+
diff --git a/xmake/modules/private/service/disconnect_service.lua b/xmake/modules/private/service/disconnect_service.lua
new file mode 100644
index 000000000..f39b29068
--- /dev/null
+++ b/xmake/modules/private/service/disconnect_service.lua
@@ -0,0 +1,28 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file disconnect_service.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main()
+ -- TODO
+end
+
diff --git a/xmake/modules/private/service/import_config.lua b/xmake/modules/private/service/import_config.lua
new file mode 100644
index 000000000..666d6c436
--- /dev/null
+++ b/xmake/modules/private/service/import_config.lua
@@ -0,0 +1,28 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file import_config.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main()
+ -- TODO
+end
+
diff --git a/xmake/modules/private/service/reconnect_service.lua b/xmake/modules/private/service/reconnect_service.lua
new file mode 100644
index 000000000..1032a3abe
--- /dev/null
+++ b/xmake/modules/private/service/reconnect_service.lua
@@ -0,0 +1,28 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file reconnect_service.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main()
+ -- TODO
+end
+
diff --git a/xmake/modules/private/service/remote_build_server/main.lua b/xmake/modules/private/service/remote_build_server.lua
index 6409e6db3..19e5f8c93 100644
--- a/xmake/modules/private/service/remote_build_server/main.lua
+++ b/xmake/modules/private/service/remote_build_server.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki
--- @file main.lua
+-- @file remote_build_server.lua
--
-- imports
diff --git a/xmake/modules/private/service/restart_service.lua b/xmake/modules/private/service/restart_service.lua
new file mode 100644
index 000000000..a21053801
--- /dev/null
+++ b/xmake/modules/private/service/restart_service.lua
@@ -0,0 +1,30 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file restart_service.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.stop_service")
+import("private.service.start_service")
+
+function main()
+ stop_service();
+ start_service({daemon = true});
+end
+
diff --git a/xmake/plugins/service/service.lua b/xmake/modules/private/service/service.lua
index 719cc8b0a..719cc8b0a 100644
--- a/xmake/plugins/service/service.lua
+++ b/xmake/modules/private/service/service.lua
diff --git a/xmake/modules/private/service/show_logs.lua b/xmake/modules/private/service/show_logs.lua
new file mode 100644
index 000000000..a0d3b7683
--- /dev/null
+++ b/xmake/modules/private/service/show_logs.lua
@@ -0,0 +1,27 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file show_logs.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main()
+end
+
diff --git a/xmake/modules/private/service/show_status.lua b/xmake/modules/private/service/show_status.lua
new file mode 100644
index 000000000..0a61fae7a
--- /dev/null
+++ b/xmake/modules/private/service/show_status.lua
@@ -0,0 +1,27 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file show_status.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main()
+end
+
diff --git a/xmake/modules/private/service/start_service.lua b/xmake/modules/private/service/start_service.lua
new file mode 100644
index 000000000..5ab440e9e
--- /dev/null
+++ b/xmake/modules/private/service/start_service.lua
@@ -0,0 +1,33 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file start_service.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main(opt)
+ opt = opt or {}
+ if opt.daemon then
+ os.execv(os.programfile(), {"lua", "private.service.service"}, {detach = true})
+ else
+ service()
+ end
+end
+
diff --git a/xmake/modules/private/service/stop_service.lua b/xmake/modules/private/service/stop_service.lua
new file mode 100644
index 000000000..723ca4416
--- /dev/null
+++ b/xmake/modules/private/service/stop_service.lua
@@ -0,0 +1,28 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file stop_service.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.service.service")
+
+function main()
+ -- TODO
+end
+
diff --git a/xmake/plugins/service/main.lua b/xmake/plugins/service/main.lua
index 8e1ba8c4b..acf0540a4 100644
--- a/xmake/plugins/service/main.lua
+++ b/xmake/plugins/service/main.lua
@@ -20,38 +20,38 @@
-- imports
import("core.base.option")
-import("service")
-
-function _start_service(opt)
- opt = opt or {}
- if opt.daemon then
- os.execv(os.programfile(), {"lua", path.join(os.scriptdir(), "service.lua")}, {detach = true})
- else
- service()
- end
-end
-
-function _restart_service()
-end
-
-function _show_service_logs()
-end
-
-function _show_service_status()
-end
+import("private.service.start_service")
+import("private.service.restart_service")
+import("private.service.stop_service")
+import("private.service.connect_service")
+import("private.service.reconnect_service")
+import("private.service.disconnect_service")
+import("private.service.import_config")
+import("private.service.show_logs")
+import("private.service.show_status")
function main()
cprint("${color.warning}It's experimental feature, still in development!")
if option.get("start") then
- _start_service({daemon = true})
+ start_service({daemon = true})
elseif option.get("restart") then
- _restart_service()
+ restart_service()
+ elseif option.get("stop") then
+ stop_service()
+ elseif option.get("connect") then
+ connect_service()
+ elseif option.get("reconnect") then
+ reconnect_service()
+ elseif option.get("disconnect") then
+ disconnect_service()
+ elseif option.get("config") then
+ import_config()
elseif option.get("logs") then
- _show_service_logs()
+ show_logs()
elseif option.get("status") then
- _show_service_status()
+ show_status()
else
- _start_service()
+ start_service()
end
end
diff --git a/xmake/plugins/service/xmake.lua b/xmake/plugins/service/xmake.lua
index 024eca0d6..a84286c02 100644
--- a/xmake/plugins/service/xmake.lua
+++ b/xmake/plugins/service/xmake.lua
@@ -25,9 +25,15 @@ task("service")
set_menu {usage = "xmake service [options]",
description = "Start service for remote or distributed compilation and etc. ${color.warning}(Experimental, still in development)",
options = {
- {nil, "start", "k", nil, "Start daemon service." },
- {nil, "restart", "k", nil, "Restart daemon service." },
- {nil, "stop" , "k", nil, "Stop daemon service." },
- {nil, "logs", "k", nil, "Show service logs if the daemon service has been started." },
- {nil, "status", "k", nil, "Show service status if the daemon service has been started." }
+ {nil, "start", "k", nil, "Start daemon service." },
+ {nil, "restart", "k", nil, "Restart daemon service." },
+ {nil, "stop" , "k", nil, "Stop daemon service." },
+ {nil, "connect" , "k", nil, "Connect the remote daemon service." },
+ {nil, "reconnect", "k", nil, "Reconnect the remote daemon service." },
+ {nil, "disconnect", "k", nil, "Disconnect the remote daemon service." },
+ {nil, "config", "kv", nil, "Import the configuration file. (default: ~/.xmake/service/config.lua)",
+ "e.g.",
+ " - xmake service --config=/tmp/config.lua" },
+ {nil, "logs", "k", nil, "Show service logs if the daemon service has been started." },
+ {nil, "status", "k", nil, "Show service status if the daemon service has been started." }
}}