summaryrefslogtreecommitdiff
path: root/xmake/plugins/service
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 /xmake/plugins/service
parent850656df9fd322bb91d62be0e5d64d8f219559f8 (diff)
add some service actions
Diffstat (limited to 'xmake/plugins/service')
-rw-r--r--xmake/plugins/service/main.lua48
-rw-r--r--xmake/plugins/service/service.lua36
-rw-r--r--xmake/plugins/service/xmake.lua16
3 files changed, 35 insertions, 65 deletions
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/service.lua b/xmake/plugins/service/service.lua
deleted file mode 100644
index 719cc8b0a..000000000
--- a/xmake/plugins/service/service.lua
+++ /dev/null
@@ -1,36 +0,0 @@
---!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 main.lua
---
-
--- imports
-import("core.base.option")
-import("core.base.scheduler")
-import("private.service.remote_build_server")
-
-function _start_remote_build_server()
- remote_build_server():runloop()
-end
-
-function main()
- local starters = {_start_remote_build_server}
- for _, start_server in ipairs(starters) do
- scheduler.co_start(start_server)
- 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." }
}}