funbuild 202306301655__py3.9.egg
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- EGG-INFO/PKG-INFO +8 -0
- EGG-INFO/SOURCES.txt +27 -0
- EGG-INFO/dependency_links.txt +1 -0
- EGG-INFO/entry_points.txt +2 -0
- EGG-INFO/not-zip-safe +1 -0
- EGG-INFO/requires.txt +1 -0
- EGG-INFO/top_level.txt +1 -0
- funbuild/__init__.py +0 -0
- funbuild/__pycache__/__init__.cpython-39.pyc +0 -0
- funbuild/core/__init__.py +1 -0
- funbuild/core/__pycache__/__init__.cpython-39.pyc +0 -0
- funbuild/core/__pycache__/core.cpython-39.pyc +0 -0
- funbuild/core/__pycache__/version.cpython-39.pyc +0 -0
- funbuild/core/core.py +187 -0
- funbuild/core/version.py +50 -0
- funbuild/git/__init__.py +0 -0
- funbuild/git/__pycache__/__init__.cpython-39.pyc +0 -0
- funbuild/git/__pycache__/repo.cpython-39.pyc +0 -0
- funbuild/git/repo.py +0 -0
- funbuild/manage/__init__.py +1 -0
- funbuild/manage/__pycache__/__init__.cpython-39.pyc +0 -0
- funbuild/manage/__pycache__/core.cpython-39.pyc +0 -0
- funbuild/manage/core.py +85 -0
- funbuild/manage/port.md +2 -0
- funbuild/manage/supervisord.conf +174 -0
- funbuild/shell/__init__.py +5 -0
- funbuild/shell/__pycache__/__init__.cpython-39.pyc +0 -0
- funbuild/shell/__pycache__/core.cpython-39.pyc +0 -0
- funbuild/shell/core.py +36 -0
- funbuild/temp/__init__.py +0 -0
- funbuild/temp/__pycache__/__init__.cpython-39.pyc +0 -0
- funbuild/temp/__pycache__/core.cpython-39.pyc +0 -0
- funbuild/temp/core.json +6 -0
- funbuild/temp/core.py +0 -0
- funbuild/tool/__init__.py +1 -0
- funbuild/tool/__pycache__/__init__.cpython-39.pyc +0 -0
- funbuild/tool/__pycache__/build.cpython-39.pyc +0 -0
- funbuild/tool/__pycache__/fastapi.cpython-39.pyc +0 -0
- funbuild/tool/build.py +7 -0
- funbuild/tool/fastapi.py +33 -0
EGG-INFO/PKG-INFO
ADDED
EGG-INFO/SOURCES.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.py
|
|
4
|
+
funbuild/__init__.py
|
|
5
|
+
funbuild.egg-info/PKG-INFO
|
|
6
|
+
funbuild.egg-info/SOURCES.txt
|
|
7
|
+
funbuild.egg-info/dependency_links.txt
|
|
8
|
+
funbuild.egg-info/entry_points.txt
|
|
9
|
+
funbuild.egg-info/requires.txt
|
|
10
|
+
funbuild.egg-info/top_level.txt
|
|
11
|
+
funbuild/core/__init__.py
|
|
12
|
+
funbuild/core/core.py
|
|
13
|
+
funbuild/core/version.py
|
|
14
|
+
funbuild/git/__init__.py
|
|
15
|
+
funbuild/git/repo.py
|
|
16
|
+
funbuild/manage/__init__.py
|
|
17
|
+
funbuild/manage/core.py
|
|
18
|
+
funbuild/manage/port.md
|
|
19
|
+
funbuild/manage/supervisord.conf
|
|
20
|
+
funbuild/shell/__init__.py
|
|
21
|
+
funbuild/shell/core.py
|
|
22
|
+
funbuild/temp/__init__.py
|
|
23
|
+
funbuild/temp/core.json
|
|
24
|
+
funbuild/temp/core.py
|
|
25
|
+
funbuild/tool/__init__.py
|
|
26
|
+
funbuild/tool/build.py
|
|
27
|
+
funbuild/tool/fastapi.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
EGG-INFO/not-zip-safe
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
EGG-INFO/requires.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GitPython
|
EGG-INFO/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
funbuild
|
funbuild/__init__.py
ADDED
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import funbuild
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
funbuild/core/core.py
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""
|
|
2
|
+
打包的工具类
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
import logging
|
|
6
|
+
import os.path
|
|
7
|
+
import time
|
|
8
|
+
from git import Repo
|
|
9
|
+
|
|
10
|
+
from funbuild.shell import run_shell, run_shell_list
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PackageBuild:
|
|
14
|
+
"""
|
|
15
|
+
打包的工具类
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, name=None):
|
|
19
|
+
self.repo_path = run_shell("git rev-parse --show-toplevel", printf=False)
|
|
20
|
+
self.name = name or self.repo_path.split('/')[-1]
|
|
21
|
+
self.repo = Repo(self.repo_path)
|
|
22
|
+
|
|
23
|
+
# self.git_url = run_shell("git remote -v", printf=False).split('\n')[0].split('\t')[1].split(' ')[0]
|
|
24
|
+
self.git_url = [url for url in self.repo.remote().urls][0]
|
|
25
|
+
|
|
26
|
+
def git_pull(self):
|
|
27
|
+
"""
|
|
28
|
+
git pull
|
|
29
|
+
"""
|
|
30
|
+
logging.info("{} pull".format(self.name))
|
|
31
|
+
# run_shell("git pull")
|
|
32
|
+
self.repo.remote().pull()
|
|
33
|
+
|
|
34
|
+
def git_push(self):
|
|
35
|
+
"""
|
|
36
|
+
git push
|
|
37
|
+
"""
|
|
38
|
+
logging.info("{} push".format(self.name))
|
|
39
|
+
run_shell_list([
|
|
40
|
+
'git add -A',
|
|
41
|
+
'git commit -a -m "add"',
|
|
42
|
+
'git push'
|
|
43
|
+
])
|
|
44
|
+
self.repo.index.add(f"{self.repo_path}/*")
|
|
45
|
+
self.repo.index.commit(message='add')
|
|
46
|
+
self.repo.remote().pull()
|
|
47
|
+
|
|
48
|
+
def git_install(self):
|
|
49
|
+
"""
|
|
50
|
+
git install
|
|
51
|
+
"""
|
|
52
|
+
logging.info('{} install'.format(self.name))
|
|
53
|
+
run_shell_list([
|
|
54
|
+
'pip uninstall {} -y'.format(self.name),
|
|
55
|
+
'python3 setup.py install',
|
|
56
|
+
'rm -rf *.egg-info',
|
|
57
|
+
'rm -rf dist',
|
|
58
|
+
'rm -rf build'
|
|
59
|
+
])
|
|
60
|
+
self.git_clear_build()
|
|
61
|
+
|
|
62
|
+
def pip_install(self):
|
|
63
|
+
"""
|
|
64
|
+
pip install
|
|
65
|
+
"""
|
|
66
|
+
run_shell('pip install -U -q git+{}'.format(self.git_url))
|
|
67
|
+
logging.info('pip install {} success'.format(self.name))
|
|
68
|
+
|
|
69
|
+
def git_clear_build(self):
|
|
70
|
+
logging.info('{} build clear'.format(self.name))
|
|
71
|
+
run_shell_list([
|
|
72
|
+
'rm -rf *.egg-info',
|
|
73
|
+
'rm -rf dist',
|
|
74
|
+
'rm -rf build',
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
def git_build(self):
|
|
78
|
+
"""
|
|
79
|
+
git build
|
|
80
|
+
"""
|
|
81
|
+
logging.info('{} build'.format(self.name))
|
|
82
|
+
self.git_pull()
|
|
83
|
+
self.git_clear_build()
|
|
84
|
+
|
|
85
|
+
set_up_file = 'setup.py'
|
|
86
|
+
if not os.path.exists(set_up_file):
|
|
87
|
+
set_up_file = 'setup2.py'
|
|
88
|
+
if not os.path.exists(set_up_file):
|
|
89
|
+
set_up_file = 'setup3.py'
|
|
90
|
+
|
|
91
|
+
run_shell_list([
|
|
92
|
+
f'python3 {set_up_file} build', # 编译
|
|
93
|
+
f'python3 {set_up_file} sdist', # 生成 tar.gz
|
|
94
|
+
f'python3 {set_up_file} bdist_egg', # 生成 egg 包
|
|
95
|
+
f'python3 {set_up_file} bdist_wheel', # 生成 wheel 包
|
|
96
|
+
|
|
97
|
+
# twine register dist/*
|
|
98
|
+
'twine upload dist/*' # 发布包
|
|
99
|
+
])
|
|
100
|
+
self.git_clear_build()
|
|
101
|
+
self.git_push()
|
|
102
|
+
self.git_tags()
|
|
103
|
+
self.pip_install()
|
|
104
|
+
|
|
105
|
+
def git_clean_history(self):
|
|
106
|
+
"""
|
|
107
|
+
git build
|
|
108
|
+
"""
|
|
109
|
+
logging.info(f'{self.name} clean history')
|
|
110
|
+
run_shell_list([
|
|
111
|
+
'git tag -d $(git tag -l) || true', # 删除本地 tag
|
|
112
|
+
'git fetch', # 拉取远程tag
|
|
113
|
+
'git push origin --delete $(git tag -l)', # 删除远程tag
|
|
114
|
+
"git tag -d $(git tag -l) || true", # 删除本地tag
|
|
115
|
+
'git checkout --orphan latest_branch', # 1.Checkout
|
|
116
|
+
'git add -A', # 2.Add all the files
|
|
117
|
+
'git commit -am "clear history"', # 3.Commit the changes
|
|
118
|
+
'git branch -D master', # 4.Delete the branch
|
|
119
|
+
'git branch -m master', # 5.Rename the current branch to master
|
|
120
|
+
'git push -f origin master', # 6.Finally, force update your repository
|
|
121
|
+
'git push --set-upstream origin master',
|
|
122
|
+
f'echo {self.name} success'
|
|
123
|
+
])
|
|
124
|
+
|
|
125
|
+
def git_clean(self):
|
|
126
|
+
"""
|
|
127
|
+
git clean
|
|
128
|
+
"""
|
|
129
|
+
logging.info('{} clean'.format(self.name))
|
|
130
|
+
run_shell_list([
|
|
131
|
+
'git rm -r --cached .',
|
|
132
|
+
'git add .',
|
|
133
|
+
"git commit -m 'update .gitignore'",
|
|
134
|
+
'git gc --aggressive',
|
|
135
|
+
])
|
|
136
|
+
|
|
137
|
+
def git_tags(self):
|
|
138
|
+
self.repo.create_tag(time.strftime("%Y%m%d%H%M", time.localtime()))
|
|
139
|
+
self.repo.remote().push()
|
|
140
|
+
self.repo.remote().push(self.repo.tags)
|
|
141
|
+
|
|
142
|
+
def git_tags_clear(self):
|
|
143
|
+
for tag in self.repo.tags:
|
|
144
|
+
self.repo.delete_tag(tag)
|
|
145
|
+
self.repo.remote().push()
|
|
146
|
+
self.repo.remote().push(self.repo.tags)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def command_line_parser():
|
|
150
|
+
parser = argparse.ArgumentParser(description="Test")
|
|
151
|
+
parser.add_argument('command')
|
|
152
|
+
args = parser.parse_args()
|
|
153
|
+
return args
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def funbuild():
|
|
157
|
+
"""
|
|
158
|
+
build tool
|
|
159
|
+
"""
|
|
160
|
+
args = command_line_parser()
|
|
161
|
+
package = PackageBuild()
|
|
162
|
+
if args.command == 'pull':
|
|
163
|
+
package.git_pull()
|
|
164
|
+
elif args.command == 'push':
|
|
165
|
+
package.git_push()
|
|
166
|
+
elif args.command == 'install':
|
|
167
|
+
package.git_install()
|
|
168
|
+
elif args.command == 'build':
|
|
169
|
+
package.git_build()
|
|
170
|
+
elif args.command == 'clean':
|
|
171
|
+
package.git_clean()
|
|
172
|
+
elif args.command == 'clean_history':
|
|
173
|
+
package.git_clean_history()
|
|
174
|
+
elif args.command == 'tags':
|
|
175
|
+
package.git_tags()
|
|
176
|
+
elif args.command == 'help':
|
|
177
|
+
info = """
|
|
178
|
+
build
|
|
179
|
+
pull
|
|
180
|
+
push
|
|
181
|
+
install
|
|
182
|
+
clean
|
|
183
|
+
clean_history
|
|
184
|
+
help
|
|
185
|
+
tags
|
|
186
|
+
"""
|
|
187
|
+
print(info)
|
funbuild/core/version.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from os import path
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class VersionManage:
|
|
5
|
+
def __init__(self, version_path='./script/__version__.md', step=32):
|
|
6
|
+
self.step = step
|
|
7
|
+
self.version_path = version_path
|
|
8
|
+
self.version_arr = [0, 0, 1]
|
|
9
|
+
self.read()
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def version(self):
|
|
13
|
+
return '.'.join([str(i) for i in self.version_arr])
|
|
14
|
+
|
|
15
|
+
def add(self):
|
|
16
|
+
step = self.step
|
|
17
|
+
version = self.version_arr
|
|
18
|
+
version2 = version[0] * step * step + version[1] * step + version[2] + 1
|
|
19
|
+
version[2] = version2 % step
|
|
20
|
+
version[1] = int(version2 / step) % step
|
|
21
|
+
version[0] = int(version2 / step / step)
|
|
22
|
+
|
|
23
|
+
self.version_arr = version
|
|
24
|
+
|
|
25
|
+
def read(self):
|
|
26
|
+
if path.exists(self.version_path):
|
|
27
|
+
with open(self.version_path, 'r') as f:
|
|
28
|
+
self.version_arr = [int(i) for i in f.read().split('.')]
|
|
29
|
+
else:
|
|
30
|
+
self.version_arr = [0, 0, 1]
|
|
31
|
+
|
|
32
|
+
def write(self):
|
|
33
|
+
with open(self.version_path, 'w') as f:
|
|
34
|
+
f.write(self.version)
|
|
35
|
+
return self.version
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_version(argv, version_path, step=10):
|
|
39
|
+
manage = VersionManage(version_path, step=step)
|
|
40
|
+
manage.read()
|
|
41
|
+
if len(argv) >= 2 and argv[1] == 'build':
|
|
42
|
+
manage.add()
|
|
43
|
+
manage.write()
|
|
44
|
+
return manage.version
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def read_version(version_path):
|
|
48
|
+
manage = VersionManage(version_path)
|
|
49
|
+
manage.read()
|
|
50
|
+
return manage.version
|
funbuild/git/__init__.py
ADDED
|
File without changes
|
|
Binary file
|
|
Binary file
|
funbuild/git/repo.py
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import BaseServer, ServerManage
|
|
Binary file
|
|
Binary file
|
funbuild/manage/core.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from funbuild.shell import run_shell
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ServerManage:
|
|
8
|
+
def __init__(self):
|
|
9
|
+
self.manage_conf_path = "/darkchats/funbuild/supervisord.conf"
|
|
10
|
+
self.conf_dir = "/darkchats/funbuild/conf"
|
|
11
|
+
|
|
12
|
+
def init(self):
|
|
13
|
+
run_shell(f"mkdir -p {self.conf_dir}")
|
|
14
|
+
run_shell(f"cp -f {os.path.abspath(os.path.dirname(__file__))}/supervisord.conf {self.manage_conf_path}")
|
|
15
|
+
|
|
16
|
+
def init2(self):
|
|
17
|
+
run_shell(f"mkdir -p {self.conf_dir}")
|
|
18
|
+
run_shell(f"echo_supervisord_conf > {self.manage_conf_path}")
|
|
19
|
+
append_data = f"""
|
|
20
|
+
[include]
|
|
21
|
+
files = {self.conf_dir}/*.ini
|
|
22
|
+
"""
|
|
23
|
+
data = open(self.manage_conf_path, 'r').read()
|
|
24
|
+
data += append_data
|
|
25
|
+
with open(self.manage_conf_path, 'w') as f:
|
|
26
|
+
f.write(data)
|
|
27
|
+
|
|
28
|
+
def start(self):
|
|
29
|
+
cmd = f"supervisord -c {self.manage_conf_path}"
|
|
30
|
+
print(cmd)
|
|
31
|
+
run_shell(cmd)
|
|
32
|
+
|
|
33
|
+
def add_job(self, server_name, directory, command, user='bingtao', stdout_logfile=None):
|
|
34
|
+
default_logfile = f'/darkchats/logs/funbuild/{server_name}.log'
|
|
35
|
+
config = f"""[program:{server_name}]
|
|
36
|
+
directory = {directory}
|
|
37
|
+
command = {command}
|
|
38
|
+
autostart = true
|
|
39
|
+
autorestart = true
|
|
40
|
+
user = {user}
|
|
41
|
+
stdout_logfile = {stdout_logfile or default_logfile}
|
|
42
|
+
"""
|
|
43
|
+
with open(f'{self.conf_dir}/{server_name}.ini', 'w') as f:
|
|
44
|
+
f.write(config)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class BaseServer:
|
|
48
|
+
def __init__(self, server_name='base_server', current_path=None, *args, **kwargs):
|
|
49
|
+
self.server_name = server_name
|
|
50
|
+
self.current_path = current_path or os.path.abspath(os.path.dirname(__file__))
|
|
51
|
+
self.manage = ServerManage()
|
|
52
|
+
self.parser = argparse.ArgumentParser()
|
|
53
|
+
self.parser.add_argument('cmd', default='unknown', help='init, stop, start, restart')
|
|
54
|
+
|
|
55
|
+
def init(self):
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
def status(self):
|
|
59
|
+
run_shell(f"supervisorctl -c {self.manage.manage_conf_path} status")
|
|
60
|
+
|
|
61
|
+
def stop(self):
|
|
62
|
+
run_shell(f"supervisorctl -c {self.manage.manage_conf_path} stop {self.server_name}")
|
|
63
|
+
|
|
64
|
+
def start(self):
|
|
65
|
+
run_shell(f"supervisorctl -c {self.manage.manage_conf_path} start {self.server_name}")
|
|
66
|
+
|
|
67
|
+
def restart(self):
|
|
68
|
+
run_shell(f"supervisorctl -c {self.manage.manage_conf_path} restart {self.server_name}")
|
|
69
|
+
|
|
70
|
+
def run(self, cmd):
|
|
71
|
+
print(cmd)
|
|
72
|
+
run_shell(cmd)
|
|
73
|
+
|
|
74
|
+
def parse_and_run(self):
|
|
75
|
+
values, unknown = self.parser.parse_known_args()
|
|
76
|
+
if values.cmd == 'init':
|
|
77
|
+
self.init()
|
|
78
|
+
elif values.cmd == 'stop':
|
|
79
|
+
self.stop()
|
|
80
|
+
elif values.cmd == 'start':
|
|
81
|
+
self.start()
|
|
82
|
+
elif values.cmd == 'restart':
|
|
83
|
+
self.restart()
|
|
84
|
+
else:
|
|
85
|
+
self.parser.print_help()
|
funbuild/manage/port.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
; Sample supervisor config file.
|
|
2
|
+
;
|
|
3
|
+
; For more information on the config file, please see:
|
|
4
|
+
; http://supervisord.org/configuration.html
|
|
5
|
+
;
|
|
6
|
+
; Notes:
|
|
7
|
+
; - Shell expansion ("~" or "$HOME") is not supported. Environment
|
|
8
|
+
; variables can be expanded using this syntax: "%(ENV_HOME)s".
|
|
9
|
+
; - Quotes around values are not supported, except in the case of
|
|
10
|
+
; the environment= options as shown below.
|
|
11
|
+
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
|
|
12
|
+
; - Command will be truncated if it looks like a config file comment, e.g.
|
|
13
|
+
; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
|
|
14
|
+
;
|
|
15
|
+
; Warning:
|
|
16
|
+
; Paths throughout this example file use /tmp because it is available on most
|
|
17
|
+
; systems. You will likely need to change these to locations more appropriate
|
|
18
|
+
; for your system. Some systems periodically delete older files in /tmp.
|
|
19
|
+
; Notably, if the socket file defined in the [unix_http_server] section below
|
|
20
|
+
; is deleted, supervisorctl will be unable to connect to supervisord.
|
|
21
|
+
|
|
22
|
+
;[unix_http_server]
|
|
23
|
+
;file=/tmp/supervisor.sock ; the path to the socket file
|
|
24
|
+
;chmod=0700 ; socket file mode (default 0700)
|
|
25
|
+
;chown=nobody:nogroup ; socket file uid:gid owner
|
|
26
|
+
;username=user ; default is no username (open server)
|
|
27
|
+
;password=123 ; default is no password (open server)
|
|
28
|
+
|
|
29
|
+
; Security Warning:
|
|
30
|
+
; The inet HTTP server is not enabled by default. The inet HTTP server is
|
|
31
|
+
; enabled by uncommenting the [inet_http_server] section below. The inet
|
|
32
|
+
; HTTP server is intended for use within a trusted environment only. It
|
|
33
|
+
; should only be bound to localhost or only accessible from within an
|
|
34
|
+
; isolated, trusted network. The inet HTTP server does not support any
|
|
35
|
+
; form of encryption. The inet HTTP server does not use authentication
|
|
36
|
+
; by default (see the username= and password= options to add authentication).
|
|
37
|
+
; Never expose the inet HTTP server to the public internet.
|
|
38
|
+
|
|
39
|
+
[inet_http_server] ; inet (TCP) server disabled by default
|
|
40
|
+
port=0.0.0.0:8101 ; ip_address:port specifier, *:port for all iface
|
|
41
|
+
;username=user ; default is no username (open server)
|
|
42
|
+
;password=123456 ; default is no password (open server)
|
|
43
|
+
|
|
44
|
+
[supervisord]
|
|
45
|
+
logfile=/tmp/supervisord.log ; main log file; default $CWD/supervisord.log
|
|
46
|
+
logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
|
|
47
|
+
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
|
|
48
|
+
loglevel=info ; log level; default info; others: debug,warn,trace
|
|
49
|
+
pidfile=/tmp/supervisord.pid ; supervisord pidfile; default supervisord.pid
|
|
50
|
+
nodaemon=false ; start in foreground if true; default false
|
|
51
|
+
silent=false ; no logs to stdout if true; default false
|
|
52
|
+
minfds=1024 ; min. avail startup file descriptors; default 1024
|
|
53
|
+
minprocs=200 ; min. avail process descriptors;default 200
|
|
54
|
+
;umask=022 ; process file creation umask; default 022
|
|
55
|
+
;user=supervisord ; setuid to this UNIX account at startup; recommended if root
|
|
56
|
+
;identifier=supervisor ; supervisord identifier, default is 'supervisor'
|
|
57
|
+
;directory=/tmp ; default is not to cd during start
|
|
58
|
+
;nocleanup=true ; don't clean up tempfiles at start; default false
|
|
59
|
+
;childlogdir=/tmp ; 'AUTO' child log dir, default $TEMP
|
|
60
|
+
;environment=KEY="value" ; key value pairs to add to environment
|
|
61
|
+
;strip_ansi=false ; strip ansi escape codes in logs; def. false
|
|
62
|
+
|
|
63
|
+
; The rpcinterface:supervisor section must remain in the config file for
|
|
64
|
+
; RPC (supervisorctl/web interface) to work. Additional interfaces may be
|
|
65
|
+
; added by defining them in separate [rpcinterface:x] sections.
|
|
66
|
+
|
|
67
|
+
[rpcinterface:supervisor]
|
|
68
|
+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
|
69
|
+
|
|
70
|
+
; The supervisorctl section configures how supervisorctl will connect to
|
|
71
|
+
; supervisord. configure it match the settings in either the unix_http_server
|
|
72
|
+
; or inet_http_server section.
|
|
73
|
+
|
|
74
|
+
[supervisorctl]
|
|
75
|
+
#serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
|
|
76
|
+
serverurl=http://0.0.0.0:8101 ; use an http:// url to specify an inet socket
|
|
77
|
+
;username=admin ; should be same as in [*_http_server] if set
|
|
78
|
+
;password=123456 ; should be same as in [*_http_server] if set
|
|
79
|
+
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
|
|
80
|
+
;history_file=~/.sc_history ; use readline history if available
|
|
81
|
+
|
|
82
|
+
; The sample program section below shows all possible program subsection values.
|
|
83
|
+
; Create one or more 'real' program: sections to be able to control them under
|
|
84
|
+
; supervisor.
|
|
85
|
+
|
|
86
|
+
;[program:theprogramname]
|
|
87
|
+
;command=/bin/cat ; the program (relative uses PATH, can take args)
|
|
88
|
+
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
|
|
89
|
+
;numprocs=1 ; number of processes copies to start (def 1)
|
|
90
|
+
;directory=/tmp ; directory to cwd to before exec (def no cwd)
|
|
91
|
+
;umask=022 ; umask for process (default None)
|
|
92
|
+
;priority=999 ; the relative start priority (default 999)
|
|
93
|
+
;autostart=true ; start at supervisord start (default: true)
|
|
94
|
+
;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
|
|
95
|
+
;startretries=3 ; max # of serial start failures when starting (default 3)
|
|
96
|
+
;autorestart=unexpected ; when to restart if exited after running (def: unexpected)
|
|
97
|
+
;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0)
|
|
98
|
+
;stopsignal=QUIT ; signal used to kill process (default TERM)
|
|
99
|
+
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
|
|
100
|
+
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
|
|
101
|
+
;killasgroup=false ; SIGKILL the UNIX process group (def false)
|
|
102
|
+
;user=chrism ; setuid to this UNIX account to run the program
|
|
103
|
+
;redirect_stderr=true ; redirect proc stderr to stdout (default false)
|
|
104
|
+
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
|
|
105
|
+
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
|
|
106
|
+
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
|
|
107
|
+
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
|
|
108
|
+
;stdout_events_enabled=false ; emit events on stdout writes (default false)
|
|
109
|
+
;stdout_syslog=false ; send stdout to syslog with process name (default false)
|
|
110
|
+
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
|
|
111
|
+
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
|
|
112
|
+
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
|
|
113
|
+
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
|
|
114
|
+
;stderr_events_enabled=false ; emit events on stderr writes (default false)
|
|
115
|
+
;stderr_syslog=false ; send stderr to syslog with process name (default false)
|
|
116
|
+
;environment=A="1",B="2" ; process environment additions (def no adds)
|
|
117
|
+
;serverurl=AUTO ; override serverurl computation (childutils)
|
|
118
|
+
|
|
119
|
+
; The sample eventlistener section below shows all possible eventlistener
|
|
120
|
+
; subsection values. Create one or more 'real' eventlistener: sections to be
|
|
121
|
+
; able to handle event notifications sent by supervisord.
|
|
122
|
+
|
|
123
|
+
;[eventlistener:theeventlistenername]
|
|
124
|
+
;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
|
|
125
|
+
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
|
|
126
|
+
;numprocs=1 ; number of processes copies to start (def 1)
|
|
127
|
+
;events=EVENT ; event notif. types to subscribe to (req'd)
|
|
128
|
+
;buffer_size=10 ; event buffer queue size (default 10)
|
|
129
|
+
;directory=/tmp ; directory to cwd to before exec (def no cwd)
|
|
130
|
+
;umask=022 ; umask for process (default None)
|
|
131
|
+
;priority=-1 ; the relative start priority (default -1)
|
|
132
|
+
;autostart=true ; start at supervisord start (default: true)
|
|
133
|
+
;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
|
|
134
|
+
;startretries=3 ; max # of serial start failures when starting (default 3)
|
|
135
|
+
;autorestart=unexpected ; autorestart if exited after running (def: unexpected)
|
|
136
|
+
;exitcodes=0 ; 'expected' exit codes used with autorestart (default 0)
|
|
137
|
+
;stopsignal=QUIT ; signal used to kill process (default TERM)
|
|
138
|
+
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
|
|
139
|
+
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
|
|
140
|
+
;killasgroup=false ; SIGKILL the UNIX process group (def false)
|
|
141
|
+
;user=chrism ; setuid to this UNIX account to run the program
|
|
142
|
+
;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners
|
|
143
|
+
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
|
|
144
|
+
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
|
|
145
|
+
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
|
|
146
|
+
;stdout_events_enabled=false ; emit events on stdout writes (default false)
|
|
147
|
+
;stdout_syslog=false ; send stdout to syslog with process name (default false)
|
|
148
|
+
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
|
|
149
|
+
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
|
|
150
|
+
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
|
|
151
|
+
;stderr_events_enabled=false ; emit events on stderr writes (default false)
|
|
152
|
+
;stderr_syslog=false ; send stderr to syslog with process name (default false)
|
|
153
|
+
;environment=A="1",B="2" ; process environment additions
|
|
154
|
+
;serverurl=AUTO ; override serverurl computation (childutils)
|
|
155
|
+
|
|
156
|
+
; The sample group section below shows all possible group values. Create one
|
|
157
|
+
; or more 'real' group: sections to create "heterogeneous" process groups.
|
|
158
|
+
|
|
159
|
+
;[group:thegroupname]
|
|
160
|
+
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
|
|
161
|
+
;priority=999 ; the relative start priority (default 999)
|
|
162
|
+
|
|
163
|
+
; The [include] section can just contain the "files" setting. This
|
|
164
|
+
; setting can list multiple files (separated by whitespace or
|
|
165
|
+
; newlines). It can also contain wildcards. The filenames are
|
|
166
|
+
; interpreted as relative to this file. Included files *cannot*
|
|
167
|
+
; include files themselves.
|
|
168
|
+
|
|
169
|
+
;[include]
|
|
170
|
+
;files = relative/directory/*.ini
|
|
171
|
+
|
|
172
|
+
[include]
|
|
173
|
+
files = /darkchats/funbuild/conf/*.ini
|
|
174
|
+
|
|
Binary file
|
|
Binary file
|
funbuild/shell/core.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import sys
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def run_shell(command: str, printf=True) -> str:
|
|
7
|
+
"""
|
|
8
|
+
执行shell命令
|
|
9
|
+
"""
|
|
10
|
+
if printf:
|
|
11
|
+
try:
|
|
12
|
+
cmd = subprocess.Popen(command, stdin=subprocess.PIPE, stderr=sys.stderr, close_fds=True,
|
|
13
|
+
stdout=sys.stdout, universal_newlines=True, shell=True, bufsize=1)
|
|
14
|
+
cmd.communicate()
|
|
15
|
+
return cmd.returncode
|
|
16
|
+
except Exception as e:
|
|
17
|
+
return f"run shell error:{e}"
|
|
18
|
+
else:
|
|
19
|
+
try:
|
|
20
|
+
outputs = subprocess.Popen(
|
|
21
|
+
command, stdout=subprocess.PIPE, shell=True).communicate()
|
|
22
|
+
outputs = [i.decode('utf-8')[:-1] for i in outputs if i is not None]
|
|
23
|
+
outputs = [i for i in outputs if len(i.strip()) > 0]
|
|
24
|
+
return ''.join(outputs)
|
|
25
|
+
except Exception as e:
|
|
26
|
+
return f"run shell error:{e}"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def run_shell_list(command_list: List[str], printf=True) -> str:
|
|
30
|
+
"""
|
|
31
|
+
批量执行shell命令
|
|
32
|
+
"""
|
|
33
|
+
# for shell in shell_list:
|
|
34
|
+
# run_shell(shell, printf=printf)
|
|
35
|
+
command = ' && '.join(command_list)
|
|
36
|
+
return run_shell(command, printf=printf)
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
funbuild/temp/core.py
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .build import read_version
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
funbuild/tool/build.py
ADDED
funbuild/tool/fastapi.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from functools import wraps
|
|
2
|
+
|
|
3
|
+
_api_routes_registry = []
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class api_route(object):
|
|
7
|
+
def __init__(self, path, **kwargs):
|
|
8
|
+
self._path = path
|
|
9
|
+
self._kwargs = kwargs
|
|
10
|
+
|
|
11
|
+
def __call__(self, fn):
|
|
12
|
+
cls, method = fn.__repr__().split(" ")[1].split(".")
|
|
13
|
+
_api_routes_registry.append(
|
|
14
|
+
{
|
|
15
|
+
"fn": fn,
|
|
16
|
+
"path": self._path,
|
|
17
|
+
"kwargs": self._kwargs,
|
|
18
|
+
"cls": cls,
|
|
19
|
+
"method": method,
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
@wraps(fn)
|
|
24
|
+
def decorated(*args, **kwargs):
|
|
25
|
+
return fn(*args, **kwargs)
|
|
26
|
+
|
|
27
|
+
return decorated
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def add_api_routes(router):
|
|
31
|
+
for reg in _api_routes_registry:
|
|
32
|
+
if router.__class__.__name__ == reg["cls"]:
|
|
33
|
+
router.add_api_route(path=reg["path"], endpoint=getattr(router, reg["method"]), **reg["kwargs"])
|