From 7c0d0f4a074d535bef4bf4f3f049d01405aae047 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Fri, 2 Aug 2024 04:00:41 +0800 Subject: [PATCH] gorse init --- .gitignore | 1 - plugins/gorse/LICENSE | 201 +++++++++++++++++++ plugins/gorse/README.md | 6 + plugins/gorse/config/gorse.toml | 90 +++++++++ plugins/gorse/ico.png | Bin 0 -> 6475 bytes plugins/gorse/index.html | 30 +++ plugins/gorse/index.py | 342 +++++++++++++++++++++++++++++++++ plugins/gorse/info.json | 18 ++ plugins/gorse/init.d/gorse.service.tpl | 13 ++ plugins/gorse/init.d/gorse.tpl | 57 ++++++ plugins/gorse/install.sh | 97 ++++++++++ plugins/gorse/js/gorse.js | 67 +++++++ plugins/gorse/tpl/gorse.toml | 252 ++++++++++++++++++++++++ 13 files changed, 1173 insertions(+), 1 deletion(-) create mode 100644 plugins/gorse/LICENSE create mode 100644 plugins/gorse/README.md create mode 100644 plugins/gorse/config/gorse.toml create mode 100644 plugins/gorse/ico.png create mode 100755 plugins/gorse/index.html create mode 100755 plugins/gorse/index.py create mode 100755 plugins/gorse/info.json create mode 100644 plugins/gorse/init.d/gorse.service.tpl create mode 100644 plugins/gorse/init.d/gorse.tpl create mode 100755 plugins/gorse/install.sh create mode 100755 plugins/gorse/js/gorse.js create mode 100644 plugins/gorse/tpl/gorse.toml diff --git a/.gitignore b/.gitignore index 29d57b084..f19ace758 100644 --- a/.gitignore +++ b/.gitignore @@ -180,4 +180,3 @@ plugins/frp plugins/file_search plugins/proxysql plugins/tidb -plugins/gorse diff --git a/plugins/gorse/LICENSE b/plugins/gorse/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/plugins/gorse/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/plugins/gorse/README.md b/plugins/gorse/README.md new file mode 100644 index 000000000..4a6bbba3e --- /dev/null +++ b/plugins/gorse/README.md @@ -0,0 +1,6 @@ +# gorse +推荐系统 + + +# 脚本安装 +cd /www/server/mdserver-web/plugins && rm -rf gorse && git clone https://github.com/mw-plugin/gorse && cd gorse && rm -rf .git && cd /www/server/mdserver-web/plugins/gorse && bash install.sh install 0.4.15 \ No newline at end of file diff --git a/plugins/gorse/config/gorse.toml b/plugins/gorse/config/gorse.toml new file mode 100644 index 000000000..f16242631 --- /dev/null +++ b/plugins/gorse/config/gorse.toml @@ -0,0 +1,90 @@ +[database] +cache_store = "{$CONFIG_REDIS}" +data_store = "mongodb://127.0.0.1:27017/gorse" + +table_prefix = "gorse_" +cache_table_prefix = "gorse_" +data_table_prefix = "gorse_" + +[master] +port = 8086 +host = "0.0.0.0" +http_port = 8088 +http_host = "0.0.0.0" +http_cors_domains = [] +http_cors_methods = [] +n_jobs = 1 +meta_timeout = "10s" +dashboard_user_name = "{$CONFIG_ADMIN}" +dashboard_password = "{$CONFIG_PASS}" +admin_api_key = "" + +[server] +default_n = 10 +api_key = "" +clock_error = "5s" +auto_insert_user = true +auto_insert_item = true +cache_expire = "10s" + +[recommend] +cache_size = 100 +cache_expire = "72h" + +[recommend.data_source] +positive_feedback_types = ["star","like"] +read_feedback_types = ["read"] +positive_feedback_ttl = 0 +item_ttl = 0 + +[recommend.popular] +popular_window = "720h" + +[recommend.user_neighbors] +neighbor_type = "similar" +enable_index = true +index_recall = 0.8 +index_fit_epoch = 3 + +[recommend.item_neighbors] +neighbor_type = "similar" +enable_index = true +index_recall = 0.8 +index_fit_epoch = 3 + +[recommend.collaborative] +enable_index = true +index_recall = 0.9 +index_fit_epoch = 3 +model_fit_period = "60m" +model_search_period = "360m" +model_search_epoch = 100 +model_search_trials = 10 +enable_model_size_search = false + +[recommend.replacement] +enable_replacement = false +positive_replacement_decay = 0.8 +read_replacement_decay = 0.6 + +[recommend.offline] +check_recommend_period = "1m" +refresh_recommend_period = "24h" +enable_latest_recommend = true +enable_popular_recommend = false +enable_user_based_recommend = true +enable_item_based_recommend = false +enable_collaborative_recommend = true +enable_click_through_prediction = true +explore_recommend = { popular = 0.1, latest = 0.2 } + +[recommend.online] +fallback_recommend = ["item_based", "latest"] +num_feedback_fallback_item_based = 10 + +[tracing] +enable_tracing = false +exporter = "jaeger" +collector_endpoint = "http://localhost:14268/api/traces" +sampler = "always" +ratio = 1 \ No newline at end of file diff --git a/plugins/gorse/ico.png b/plugins/gorse/ico.png new file mode 100644 index 0000000000000000000000000000000000000000..01be3257a26e834f38a1e52f01112e78cc98c3fc GIT binary patch literal 6475 zcmcIoRalf!*L`WEh7b^t9O*{78|m(D25E-w96&-+LSiH(1Ze~$rDNzW=?0}FKmN=A z;=BCL^X$FO+Rs`Sd+&2~Vl~thaIwg-006*Md?%~*j2F*wgo*N;q0j)~XF#==Qk4RL z?@8GAmT1qM#`>L>DggL106=IY0Ng&8LiYf`iwgh_EC4__697ovKL5}Z1pwp{4HX@^ zr>Cc9&Hw12qob3Nk-dHUR!B%lMMcHV&Q4ofTT)VzhK7cSh=_rK!O+kU2M0%9Uf#mO zf{l%hnwlCPAD zadKU+`o~Kq7RRX#bX;7;v|Q=vB-6G5N5qOFVwH=F3mq4aQA3Xp;>N0PiuIBh1qB5R z2BTtPhJ=K0a&lHzS3kGEwzk&M(UFvtWNvOQAtB-F>YAUQe|mZf0)f=k)yK!jf!7>> zpc$Z>0H}ol+*$xJm=gdb0Dzd41Hixrtcw8mHh@JQ1OTo8&;bC?104r|Bmkg(9;;&w z02V%dzQ}v2KWCGyd;kamfH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`frO4Iv(i5@~^0!ejjGm z+-x^!@2(@65KAs3d5E7Ni&M{Ya{rYKW70npP6hI1U^%>Rii~WYqBliA0{X?B@f}C2 zq|gBA)Pj}aW6wq*c$JnUbv#u8Mmz^k)An45;-z&NE}hD9;wWwtx1E+)|6B5!LP)fz z6$jmH-e`m_E8@v~_OUOvkg*+W*=?T@lz^vgmh{$tUc#-{XMCX3{Ryr~caL8{NhY|{ zs=vJsd`u0NO6;LF`nLFlL7=6TK?+kc-VP( ybhvngd4+_z_*uEQgt@qsih8O3pTXJH24d&;-wh)F0>3;P07W@9*>BPo;r{`kJNu>p literal 0 HcmV?d00001 diff --git a/plugins/gorse/index.html b/plugins/gorse/index.html new file mode 100755 index 000000000..80316d979 --- /dev/null +++ b/plugins/gorse/index.html @@ -0,0 +1,30 @@ + + +
+
+
+
+

服务

+

自启动

+

配置修改

+

运行日志

+

相关说明

+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/plugins/gorse/index.py b/plugins/gorse/index.py new file mode 100755 index 000000000..7d08a356a --- /dev/null +++ b/plugins/gorse/index.py @@ -0,0 +1,342 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import re + +sys.path.append(os.getcwd() + "/class/core") +import mw + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'gorse' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getInitDFile(): + current_os = mw.getOs() + if current_os == 'darwin': + return '/tmp/' + getPluginName() + + if current_os.startswith('freebsd'): + return '/etc/rc.d/' + getPluginName() + + return '/etc/init.d/' + getPluginName() + + +def getConf(): + path = getServerDir() + "/gorse.toml" + return path + + +def getConfTpl(): + path = getPluginDir() + "/config/gorse.toml" + return path + + +def getInitDTpl(): + path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl" + return path + + +def getArgs(): + args = sys.argv[3:] + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + if t.strip() == '': + tmp = [] + else: + t = t.split(':',1) + tmp[t[0]] = t[1] + tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':',1) + tmp[t[0]] = t[1] + return tmp + +def checkArgs(data, ck=[]): + for i in range(len(ck)): + if not ck[i] in data: + return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) + return (True, mw.returnJson(True, 'ok')) + +def configTpl(): + path = getPluginDir() + '/tpl' + pathFile = os.listdir(path) + tmp = [] + for one in pathFile: + file = path + '/' + one + tmp.append(file) + return mw.getJson(tmp) + + +def readConfigTpl(): + args = getArgs() + data = checkArgs(args, ['file']) + if not data[0]: + return data[1] + + content = mw.readFile(args['file']) + content = contentReplace(content) + return mw.returnJson(True, 'ok', content) + +def getPidFile(): + file = getConf() + content = mw.readFile(file) + rep = r'pidfile\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + +def status(): + # pid_file = getPidFile() + # if not os.path.exists(pid_file): + # return 'stop' + + cmd = "ps aux|grep gorse |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'" + data = mw.execShell(cmd) + + if data[0] == '': + return 'stop' + return 'start' + + +def initRedisConf(): + requirepass = "" + conf = mw.getServerDir() + '/redis/redis.conf' + content = mw.readFile(conf) + rep = r"^(requirepass" + r')\s*([.0-9A-Za-z_& ~]+)' + tmp = re.search(rep, content, re.M) + if tmp: + requirepass = tmp.groups()[1] + + port = "6379" + rep = r"^(port)\s*([.0-9A-Za-z_& ~]+)" + tmp = re.search(rep, content, re.M) + if tmp: + port = tmp.groups()[1] + + return 'redis://:'+requirepass+'@127.0.0.1:'+port+'/3' + +def contentReplace(content): + service_path = mw.getServerDir() + content = content.replace('{$ROOT_PATH}', mw.getRootDir()) + content = content.replace('{$SERVER_PATH}', service_path) + content = content.replace('{$CONFIG_ADMIN}', mw.getRandomString(6)) + content = content.replace('{$CONFIG_PASS}', mw.getRandomString(10)) + content = content.replace('{$CONFIG_REDIS}', initRedisConf()) + return content + + +def initDreplace(): + + file_tpl = getInitDTpl() + service_path = os.path.dirname(os.getcwd()) + + initD_path = getServerDir() + '/init.d' + if not os.path.exists(initD_path): + mw.execShell("mkdir -p " + initD_path) + + file_bin = initD_path + '/' + getPluginName() + + # initd replace + if not os.path.exists(file_bin): + content = mw.readFile(file_tpl) + content = content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + # log + dataLog = getServerDir() + '/data' + if not os.path.exists(dataLog): + mw.execShell('chmod +x ' + file_bin) + + # config replace + dst_conf = getServerDir() + '/gorse.toml' + dst_conf_init = getServerDir() + '/init.pl' + if not os.path.exists(dst_conf_init): + content = mw.readFile(getConfTpl()) + content = content.replace('{$SERVER_PATH}', service_path) + content = contentReplace(content) + mw.writeFile(dst_conf, content) + mw.writeFile(dst_conf_init, 'ok') + + # systemd + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/' + getPluginName() + '.service' + if os.path.exists(systemDir) and not os.path.exists(systemService): + systemServiceTpl = getPluginDir() + '/init.d/' + getPluginName() + '.service.tpl' + service_path = mw.getServerDir() + content = mw.readFile(systemServiceTpl) + content = content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(systemService, se_content) + mw.execShell('systemctl daemon-reload') + + return file_bin + + +def gorseOp(method): + file = initDreplace() + + # print(file) + + current_os = mw.getOs() + if current_os == "darwin": + data = mw.execShell(file + ' ' + method) + if data[1] == '': + return 'ok' + return data[1] + + if current_os.startswith("freebsd"): + data = mw.execShell('service ' + getPluginName() + ' ' + method) + if data[1] == '': + return 'ok' + return data[1] + + data = mw.execShell('systemctl ' + method + ' ' + getPluginName()) + if data[1] == '': + return 'ok' + return data[1] + + +def start(): + return gorseOp('start') + + +def stop(): + return gorseOp('stop') + + +def restart(): + status = gorseOp('restart') + log_file = runLog() + mw.execShell("echo '' > " + log_file) + return status + + +def reload(): + return gorseOp('reload') + + +def getPort(): + conf = getServerDir() + '/gorse.conf' + content = mw.readFile(conf) + + rep = "^(" + 'port' + ')\s*([.0-9A-Za-z_& ~]+)' + tmp = re.search(rep, content, re.M) + if tmp: + return tmp.groups()[1] + + return '6379' + + +def initdStatus(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + if current_os.startswith('freebsd'): + initd_bin = getInitDFile() + if os.path.exists(initd_bin): + return 'ok' + + shell_cmd = 'systemctl status ' + getPluginName() + ' | grep loaded | grep "enabled;"' + data = mw.execShell(shell_cmd) + if data[0] == '': + return 'fail' + return 'ok' + + +def initdInstall(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + # freebsd initd install + if current_os.startswith('freebsd'): + import shutil + source_bin = initDreplace() + initd_bin = getInitDFile() + shutil.copyfile(source_bin, initd_bin) + mw.execShell('chmod +x ' + initd_bin) + mw.execShell('sysrc ' + getPluginName() + '_enable="YES"') + return 'ok' + + mw.execShell('systemctl enable ' + getPluginName()) + return 'ok' + + +def initdUinstall(): + current_os = mw.getOs() + if current_os == 'darwin': + return "Apple Computer does not support" + + if current_os.startswith('freebsd'): + initd_bin = getInitDFile() + os.remove(initd_bin) + mw.execShell('sysrc ' + getPluginName() + '_enable="NO"') + return 'ok' + + mw.execShell('systemctl disable ' + getPluginName()) + return 'ok' + + +def runLog(): + return getServerDir() + '/logs.pl' + +def installPreInspection(): + redis_path = mw.getServerDir() + "/redis" + if not os.path.exists(redis_path): + return "默认需要安装Redis" + + mongodb_path = mw.getServerDir() + "/mongodb" + if not os.path.exists(mongodb_path): + return "默认需要安装MongoDB" + return 'ok' + +if __name__ == "__main__": + func = sys.argv[1] + if func == 'status': + print(status()) + elif func == 'start': + print(start()) + elif func == 'stop': + print(stop()) + elif func == 'restart': + print(restart()) + elif func == 'reload': + print(reload()) + elif func == 'initd_status': + print(initdStatus()) + elif func == 'initd_install': + print(initdInstall()) + elif func == 'initd_uninstall': + print(initdUinstall()) + elif func == 'install_pre_inspection': + print(installPreInspection()) + elif func == 'conf': + print(getConf()) + elif func == 'run_log': + print(runLog()) + elif func == 'config_tpl': + print(configTpl()) + elif func == 'read_config_tpl': + print(readConfigTpl()) + else: + print('error') diff --git a/plugins/gorse/info.json b/plugins/gorse/info.json new file mode 100755 index 000000000..f59675053 --- /dev/null +++ b/plugins/gorse/info.json @@ -0,0 +1,18 @@ +{ + "sort": 7, + "ps": "一款高效简单的推荐系统[单机]", + "name": "gorse", + "title": "Gorse", + "shell": "install.sh", + "versions":["0.4.15"], + "tip": "soft", + "install_pre_inspection":true, + "checks": "server/gorse", + "path": "server/gorse", + "display": 1, + "author": "midoks", + "date": "2024-06-12", + "home": "https://gorse.io/zh/docs/master/deploy/binary.html", + "type": 0, + "pid": "5" +} diff --git a/plugins/gorse/init.d/gorse.service.tpl b/plugins/gorse/init.d/gorse.service.tpl new file mode 100644 index 000000000..9e0c94cf5 --- /dev/null +++ b/plugins/gorse/init.d/gorse.service.tpl @@ -0,0 +1,13 @@ +[Unit] +Description=Gorse, an open source recommender system service written in Go. +After=network.target + +[Service] +Type=simple +Restart=always +ExecStart={$SERVER_PATH}/gorse/bin/gorse-in-one -c {$SERVER_PATH}/gorse/gorse.toml \ + --log-path {$SERVER_PATH}/gorse/gorse.log \ + --cache-path {$SERVER_PATH}/gorse/data/cache.data + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/plugins/gorse/init.d/gorse.tpl b/plugins/gorse/init.d/gorse.tpl new file mode 100644 index 000000000..be9c7bbcc --- /dev/null +++ b/plugins/gorse/init.d/gorse.tpl @@ -0,0 +1,57 @@ +#!/bin/sh +# chkconfig: 2345 55 25 +# description: Gorse Service + +### BEGIN INIT INFO +# Provides: Gorse +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts Gorse +# Description: starts the MDW-Web +### END INIT INFO + +# Simple Gorse init.d script conceived to work on Linux systems +# as it does use of the /proc filesystem. + +CONF="{$SERVER_PATH}/gorse/gorse.toml" + +APP_DIR={$SERVER_PATH}/gorse + +app_start(){ + echo "Starting Gorse server..." + echo "$APP_DIR/bin/gorse-in-one -c $CONF" + nohup $APP_DIR/bin/gorse-in-one -c $CONF >> {$SERVER_PATH}/gorse/logs.pl 2>&1 & +} + +app_stop(){ + echo "Stopping ..." + + find_gorse=`ps -ef | grep gorse | grep -v grep | awk "{print $2}"` + for p in ${find_gorse[@]} + do + kill -9 $p > /dev/null 2>&1 + done + + echo "Gorse stopped" +} + + +case "$1" in + start) + app_start + ;; + stop) + app_stop + ;; + restart|reload) + app_stop + sleep 0.3 + app_start + ;; + *) + echo "Please use start or stop as first argument" + ;; +esac + diff --git a/plugins/gorse/install.sh b/plugins/gorse/install.sh new file mode 100755 index 000000000..e34f521c7 --- /dev/null +++ b/plugins/gorse/install.sh @@ -0,0 +1,97 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") +sysName=`uname` +sysArch=`arch` + +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/gorse && bash install.sh install 0.4.15 +# cd /www/server/mdserver-web/plugins/gorse && bash install.sh install 0.4.15 + + +install_tmp=${rootPath}/tmp/mw_install.pl +VERSION=$2 + +Install_App() +{ + echo '正在安装脚本文件...' > $install_tmp + mkdir -p $serverPath/source + mkdir -p $serverPath/source/gorse + + SYSNAME=linux + if [ "$sysName" == "Darwin" ];then + SYSNAME=darwin + fi + + ARCH="amd64" + if [ "$sysArch" == "x86_64" ];then + ARCH="amd64" + elif [ "$sysArch" == "aarch64" ];then + ARCH="arm64" + elif [ "$sysArch" == "arm64" ];then + ARCH="arm64" + else + ARCH="amd64" + fi + + FILE_TGZ=gorse_${SYSNAME}_${ARCH}.zip + GORSE_DIR=$serverPath/source/gorse + + # https://github.com/gorse-io/gorse/releases/download/v0.4.15/gorse_linux_amd64.zip + echo "https://github.com/gorse-io/gorse/releases/download/v${VERSION}/${FILE_TGZ}" + + if [ ! -f $GORSE_DIR/${FILE_TGZ} ];then + wget -O $GORSE_DIR/${FILE_TGZ} https://github.com/gorse-io/gorse/releases/download/v${VERSION}/${FILE_TGZ} + fi + + mkdir -p $serverPath/gorse/bin + mkdir -p $serverPath/gorse/logs + cd $GORSE_DIR && unzip -d $serverPath/gorse/bin ${FILE_TGZ} + + mkdir -p $serverPath/gorse/data + echo "${VERSION}" > $serverPath/gorse/version.pl + echo '安装Gorse完成' + cd ${rootPath} && python3 ${rootPath}/plugins/gorse/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/gorse/index.py initd_install + + if [ -d ${GORSE_DIR}/gorse-${VERSION} ];then + rm -rf ${GORSE_DIR}/gorse-${VERSION} + fi +} + +Uninstall_App() +{ + app_name=gorse + systemctl_dir=/lib/systemd/system + if [ -d /usr/lib/systemd/system ];then + systemctl_dir=/usr/lib/systemd/system + fi + + if [ -f ${systemctl_dir}/${app_name}.service ];then + systemctl stop ${app_name} + systemctl disable ${app_name} + rm -rf ${systemctl_dir}/${app_name}.service + systemctl daemon-reload + fi + + if [ -f $serverPath/${app_name}/initd/${app_name} ];then + $serverPath/${app_name}/initd/${app_name} stop + fi + + if [ -d $serverPath/${app_name} ];then + rm -rf $serverPath/${app_name} + fi + + echo "卸载Gorse成功" +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_App +else + Uninstall_App +fi diff --git a/plugins/gorse/js/gorse.js b/plugins/gorse/js/gorse.js new file mode 100755 index 000000000..0516a714d --- /dev/null +++ b/plugins/gorse/js/gorse.js @@ -0,0 +1,67 @@ +function gorsePost(method, version, args,callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + + var req_data = {}; + req_data['name'] = 'gorse'; + req_data['func'] = method; + req_data['version'] = version; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(toArrayObject(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/run', req_data, function(data) { + layer.close(loadT); + if (!data.status){ + //错误展示10S + layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +function gorsePostCallbak(method, version, args,callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + + var req_data = {}; + req_data['name'] = 'gorse'; + req_data['func'] = method; + args['version'] = version; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(toArrayObject(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/callback', req_data, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + + +function gorseReadme(){ + + + var readme = ''; + + $('.soft-man-con').html(readme); +} + diff --git a/plugins/gorse/tpl/gorse.toml b/plugins/gorse/tpl/gorse.toml new file mode 100644 index 000000000..127bf91eb --- /dev/null +++ b/plugins/gorse/tpl/gorse.toml @@ -0,0 +1,252 @@ +[database] + +# The database for caching, support Redis, MySQL, Postgres and MongoDB: +# redis://:@:/ +# rediss://:@:/ +# redis+cluster://:@:,:,...,: +# postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full +# postgresql://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full +# mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]] +# mongodb+srv://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]] +cache_store = "redis://localhost:6379/0" + +# The database for persist data, support MySQL, Postgres, ClickHouse and MongoDB: +# mysql://[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] +# postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full +# postgresql://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full +# clickhouse://user:password@host[:port]/database?param1=value1&...¶mN=valueN +# chhttp://user:password@host[:port]/database?param1=value1&...¶mN=valueN +# chhttps://user:password@host[:port]/database?param1=value1&...¶mN=valueN +# mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]] +# mongodb+srv://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]] +data_store = "mysql://gorse:gorse_pass@tcp(localhost:3306)/gorse" + +# The naming prefix for tables (collections, keys) in databases. The default value is empty. +table_prefix = "" + +# The naming prefix for tables (collections, keys) in cache storage databases. The default value is `table_prefix`. +cache_table_prefix = "" + +# The naming prefix for tables (collections, keys) in data storage databases. The default value is `table_prefix`. +data_table_prefix = "" + +[master] + +# GRPC port of the master node. The default value is 8086. +port = 8086 + +# gRPC host of the master node. The default values is "0.0.0.0". +host = "0.0.0.0" + +# HTTP port of the master node. The default values is 8088. +http_port = 8088 + +# HTTP host of the master node. The default values is "0.0.0.0". +http_host = "0.0.0.0" + +# AllowedDomains is a list of allowed values for Http Origin. +# The list may contain the special wildcard string ".*" ; all is allowed +# If empty all are allowed. +http_cors_domains = [] + +# AllowedMethods is either empty or has a list of http methods names. Checking is case-insensitive. +http_cors_methods = [] + +# Number of working jobs in the master node. The default value is 1. +n_jobs = 1 + +# Meta information timeout. The default value is 10s. +meta_timeout = "10s" + +# Username for the master node dashboard. +dashboard_user_name = "" + +# Password for the master node dashboard. +dashboard_password = "" + +# Secret key for admin APIs (SSL required). +admin_api_key = "" + +[server] + +# Default number of returned items. The default value is 10. +default_n = 10 + +# Secret key for RESTful APIs (SSL required). +api_key = "" + +# Clock error in the cluster. The default value is 5s. +clock_error = "5s" + +# Insert new users while inserting feedback. The default value is true. +auto_insert_user = true + +# Insert new items while inserting feedback. The default value is true. +auto_insert_item = true + +# Server-side cache expire time. The default value is 10s. +cache_expire = "10s" + +[recommend] + +# The cache size for recommended/popular/latest items. The default value is 10. +cache_size = 100 + +# Recommended cache expire time. The default value is 72h. +cache_expire = "72h" + +[recommend.data_source] + +# The feedback types for positive events. +positive_feedback_types = ["star","like"] + +# The feedback types for read events. +read_feedback_types = ["read"] + +# The time-to-live (days) of positive feedback, 0 means disabled. The default value is 0. +positive_feedback_ttl = 0 + +# The time-to-live (days) of items, 0 means disabled. The default value is 0. +item_ttl = 0 + +[recommend.popular] + +# The time window of popular items. The default values is 4320h. +popular_window = "720h" + +[recommend.user_neighbors] + +# The type of neighbors for users. There are three types: +# similar: Neighbors are found by number of common labels. +# related: Neighbors are found by number of common liked items. +# auto: If a user have labels, neighbors are found by number of common labels. +# If this user have no labels, neighbors are found by number of common liked items. +# The default value is "auto". +neighbor_type = "similar" + +# Enable approximate user neighbor searching using vector index. The default value is true. +enable_index = true + +# Minimal recall for approximate user neighbor searching. The default value is 0.8. +index_recall = 0.8 + +# Maximal number of fit epochs for approximate user neighbor searching vector index. The default value is 3. +index_fit_epoch = 3 + +[recommend.item_neighbors] + +# The type of neighbors for items. There are three types: +# similar: Neighbors are found by number of common labels. +# related: Neighbors are found by number of common users. +# auto: If a item have labels, neighbors are found by number of common labels. +# If this item have no labels, neighbors are found by number of common users. +# The default value is "auto". +neighbor_type = "similar" + +# Enable approximate item neighbor searching using vector index. The default value is true. +enable_index = true + +# Minimal recall for approximate item neighbor searching. The default value is 0.8. +index_recall = 0.8 + +# Maximal number of fit epochs for approximate item neighbor searching vector index. The default value is 3. +index_fit_epoch = 3 + +[recommend.collaborative] + +# Enable approximate collaborative filtering recommend using vector index. The default value is true. +enable_index = true + +# Minimal recall for approximate collaborative filtering recommend. The default value is 0.9. +index_recall = 0.9 + +# Maximal number of fit epochs for approximate collaborative filtering recommend vector index. The default value is 3. +index_fit_epoch = 3 + +# The time period for model fitting. The default value is "60m". +model_fit_period = "60m" + +# The time period for model searching. The default value is "360m". +model_search_period = "360m" + +# The number of epochs for model searching. The default value is 100. +model_search_epoch = 100 + +# The number of trials for model searching. The default value is 10. +model_search_trials = 10 + +# Enable searching models of different sizes, which consume more memory. The default value is false. +enable_model_size_search = false + +[recommend.replacement] + +# Replace historical items back to recommendations. The default value is false. +enable_replacement = false + +# Decay the weights of replaced items from positive feedbacks. The default value is 0.8. +positive_replacement_decay = 0.8 + +# Decay the weights of replaced items from read feedbacks. The default value is 0.6. +read_replacement_decay = 0.6 + +[recommend.offline] + +# The time period to check recommendation for users. The default values is 1m. +check_recommend_period = "1m" + +# The time period to refresh recommendation for inactive users. The default values is 120h. +refresh_recommend_period = "24h" + +# Enable latest recommendation during offline recommendation. The default value is false. +enable_latest_recommend = true + +# Enable popular recommendation during offline recommendation. The default value is false. +enable_popular_recommend = false + +# Enable user-based similarity recommendation during offline recommendation. The default value is false. +enable_user_based_recommend = true + +# Enable item-based similarity recommendation during offline recommendation. The default value is false. +enable_item_based_recommend = false + +# Enable collaborative filtering recommendation during offline recommendation. The default value is true. +enable_collaborative_recommend = true + +# Enable click-though rate prediction during offline recommendation. Otherwise, results from multi-way recommendation +# would be merged randomly. The default value is false. +enable_click_through_prediction = true + +# The explore recommendation method is used to inject popular items or latest items into recommended result: +# popular: Recommend popular items to cold-start users. +# latest: Recommend latest items to cold-start users. +# The default values is { popular = 0.0, latest = 0.0 }. +explore_recommend = { popular = 0.1, latest = 0.2 } + +[recommend.online] + +# The fallback recommendation method is used when cached recommendation drained out: +# item_based: Recommend similar items to cold-start users. +# popular: Recommend popular items to cold-start users. +# latest: Recommend latest items to cold-start users. +# Recommenders are used in order. The default values is ["latest"]. +fallback_recommend = ["item_based", "latest"] + +# The number of feedback used in fallback item-based similar recommendation. The default values is 10. +num_feedback_fallback_item_based = 10 + +[tracing] + +# Enable tracing for REST APIs. The default value is false. +enable_tracing = false + +# The type of tracing exporters should be one of "jaeger", "zipkin", "otlp" and "otlphttp". The default value is "jaeger". +exporter = "jaeger" + +# The endpoint of tracing collector. +collector_endpoint = "http://localhost:14268/api/traces" + +# The type of tracing sampler should be one of "always", "never" and "ratio". The default value is "always". +sampler = "always" + +# The ratio of ratio based sampler. The default value is 1. +ratio = 1 \ No newline at end of file