Skip to content

Commit

Permalink
Added systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
toshsan committed Oct 10, 2023
1 parent c2ddbc4 commit 9a1cddc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 37 deletions.
8 changes: 2 additions & 6 deletions bin/server
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/usr/bin/env python3

import uvicorn
from embedding_server import server
from embedding_server.server import app

if __name__ == "__main__":
uvicorn.run(
server.app,
host="0.0.0.0",
port=8080,
)
uvicorn.run(app,host="0.0.0.0",port=8000)
10 changes: 7 additions & 3 deletions embedding_server/__main__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import uvicorn
from server import app
from embedding_server.server import app

if __name__ == "__main__":
def main():
uvicorn.run(
app,
host="0.0.0.0",
port=8080,
)
)


if __name__ == "__main__":
main()
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
server = "embedding_server.server:main"
server = "embedding_server:main"

[project.scripts]
embedding-server = "embedding_server:main"
29 changes: 2 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
from setuptools import setup, find_packages
from setuptools import setup

VERSION = "0.2.0"
DESCRIPTION = "Embedding Server"
LONG_DESCRIPTION = "Drop in replacement for OpenAI's embedding API. Can be used with official OpenAPI libraries"

# Setting up
setup(
name="embedding_server",
version=VERSION,
author="Tosh San",
author_email="[email protected]",
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
packages=find_packages(),
install_requires=["fastapi", "sentence-transformers", "uvicorn"],
keywords=["python", "embeddings", "fastapi", "openai", "pytorch", "transformers"],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Education",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
],
package_data={'embedding-server': ['bin/server']},
scripts=['embedding_server/bin/server']
)
setup()
8 changes: 8 additions & 0 deletions systemd/embedding-server.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Embedding Server
After=multi-user.target[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 -m embedding_server
WantedBy=multi-user.target
DynamicUser=yes

0 comments on commit 9a1cddc

Please sign in to comment.