virtual environments
This commit is contained in:
17
README.md
17
README.md
@@ -2,21 +2,30 @@
|
|||||||
|
|
||||||
Start proxied matlab instances from a webpage using Nginx.
|
Start proxied matlab instances from a webpage using Nginx.
|
||||||
|
|
||||||
## Preequisites
|
## Prerequisites
|
||||||
|
|
||||||
Linux with Matlab and Python3
|
Linux with Matlab and Python3
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
make matlabhub/config.py:
|
edit matlabhub/config.py:
|
||||||
|
|
||||||
license_file: 'path_to_license.lic'
|
license_file: 'path_to_license.lic'
|
||||||
port_range: [10000, 65536]
|
port_range: [10000, 65536]
|
||||||
|
matlab-proxy-app: '/opt/matlabhub/venv/bin/matlab-proxy-app' # path to matlab-proxy-app in venv
|
||||||
|
|
||||||
|
edit ExecStart to point to gunicorn in python venv in matlab.service:
|
||||||
|
|
||||||
|
ExecStart=/opt/matlabhub/venv/bin/gunicorn --bind unix:/tmp/matlabhub.sock matlabhub.app:app
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
||||||
sudo apt install nginx screen
|
sudo apt install nginx screen xvfb
|
||||||
sudo pip install matlabhub
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
|
. .bashrc
|
||||||
|
uv venv venv --python 3.11
|
||||||
|
. venv/bin/activate
|
||||||
|
pip install matlabhub
|
||||||
sudo cp matlab /etc/nginx/sites-available/
|
sudo cp matlab /etc/nginx/sites-available/
|
||||||
sudo ln -s /etc/nginx/sites-available/matlab /etc/nginx/sites-enabled/matlab
|
sudo ln -s /etc/nginx/sites-available/matlab /etc/nginx/sites-enabled/matlab
|
||||||
sudo cp matlab.service /lib/systemd/system/
|
sudo cp matlab.service /lib/systemd/system/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Wants=network-online.target
|
|||||||
[Service]
|
[Service]
|
||||||
User=matlab-user
|
User=matlab-user
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/local/bin/gunicorn --bind unix:/tmp/matlabhub.sock matlabhub.app:app
|
ExecStart=/opt/matlabhub/venv/bin/gunicorn --bind unix:/tmp/matlabhub.sock matlabhub.app:app
|
||||||
ExecStop=/bin/kill -s STOP $MAINPID
|
ExecStop=/bin/kill -s STOP $MAINPID
|
||||||
ExecReload=/bin/kill -s HUP $MAINPID
|
ExecReload=/bin/kill -s HUP $MAINPID
|
||||||
TimeoutSec=0
|
TimeoutSec=0
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import random
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import random
|
import sys
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from flask import Flask, redirect, render_template, request
|
from flask import Flask, redirect, render_template, request
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), 'config.yml')) as conf_file:
|
with open(os.path.join(os.path.dirname(__file__), 'config.yml')) as conf_file:
|
||||||
config = yaml.safe_load(conf_file)
|
config = yaml.safe_load(conf_file)
|
||||||
@@ -25,7 +26,9 @@ class Matlab:
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
command = f'screen -S {self.screen_name} -d -m env MWI_BASE_URL="/{self.port}" ' \
|
command = f'screen -S {self.screen_name} -d -m env MWI_BASE_URL="/{self.port}" ' \
|
||||||
f'MWI_APP_PORT={self.port} MLM_LICENSE_FILE={config["license_file"]} matlab-proxy-app'
|
f'MWI_APP_PORT={self.port} MLM_LICENSE_FILE={config["license_file"]} ' \
|
||||||
|
'MWI_ENABLE_TOKEN_AUTH="False" ' \
|
||||||
|
f'{config["matlab-proxy-app"]}'
|
||||||
subprocess.Popen(command, shell=True, start_new_session=True)
|
subprocess.Popen(command, shell=True, start_new_session=True)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|||||||
32
pyproject.toml
Normal file
32
pyproject.toml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
[project]
|
||||||
|
name = "matlabhub"
|
||||||
|
version = "2025.3.0"
|
||||||
|
description = "matlabhub"
|
||||||
|
authors = [
|
||||||
|
{ name = "W. Pomp", email = "w.pomp@nki.nl" }
|
||||||
|
]
|
||||||
|
license = { text = "GPL-3.0-or-later"}
|
||||||
|
readme = "README.md"
|
||||||
|
keywords = ["matlab", "hub", "proxy-app"]
|
||||||
|
include = ["templates/*", "config.yml"]
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
"flask",
|
||||||
|
"gunicorn",
|
||||||
|
"matlab-proxy",
|
||||||
|
"pyyaml",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
repository = "https://github.com/wimpomp/matlabhub"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
matlabhub = "matlabhub:main"
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
line_length = 119
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
26
setup.py
26
setup.py
@@ -1,26 +0,0 @@
|
|||||||
import setuptools
|
|
||||||
|
|
||||||
with open('README.md', 'r') as fh:
|
|
||||||
long_description = fh.read()
|
|
||||||
|
|
||||||
setuptools.setup(
|
|
||||||
name='matlabhub',
|
|
||||||
version='2022.7.0',
|
|
||||||
author='Wim Pomp @ Lenstra lab NKI',
|
|
||||||
author_email='w.pomp@nki.nl',
|
|
||||||
description='matlabhub',
|
|
||||||
long_description=long_description,
|
|
||||||
long_description_content_type='text/markdown',
|
|
||||||
url='https://github.com/wimpomp/matlabhub',
|
|
||||||
packages=['matlabhub'],
|
|
||||||
classifiers=[
|
|
||||||
'Programming Language :: Python :: 3',
|
|
||||||
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
|
|
||||||
'Operating System :: OS Independent',
|
|
||||||
],
|
|
||||||
python_requires='>=3.8',
|
|
||||||
install_requires=['matlab-proxy', 'flask', 'gunicorn', 'pyyaml'],
|
|
||||||
entry_points={'console_scripts': ['matlabhub=matlabhub:main'], },
|
|
||||||
package_data={'': ['templates/*', 'config.yml']},
|
|
||||||
include_package_data=True,
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user