updated upload folder path

pull/135/head
13621160019@163.com 2022-03-19 14:01:03 +08:00
parent 90e097306f
commit 56588a7c0d
7 changed files with 57 additions and 43 deletions

View File

@ -1,10 +1,12 @@
# myems-admin
## Introduction
系统管理用户界面用于MyEMS系统配置
Providing Admin UI for MyEMS system settings
Admin UI for MyEMS system settings
## Prerequisites
nginx-1.18.0 or later

View File

@ -2,7 +2,7 @@ FROM python:slim
WORKDIR /code
# todo: share upload folder with admin container on Docker
RUN mkdir -p /var/www/html/admin/upload
RUN mkdir -p /var/www/myems-admin/upload
COPY . /code
RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

View File

@ -1,7 +1,8 @@
# MyEMS API Service
## Introduction
Providing RESTful API service for [MyEMS](https://github.com/MyEMS/myems) components and third party applications.
RESTful API service for [MyEMS](https://github.com/MyEMS/myems) components and third party applications.
## Prerequisites
@ -71,12 +72,12 @@ docker build -t myems/myems-api .
On Windows host, bind-mount a share upload folder at c:\myems-upload to the container,
and also bind-mount the .env to the container:
```bash
docker run -d -p 8000:8000 -v c:\myems-upload:/var/www/html/admin/upload -v c:\myems-api\.env:/code/.env --restart always --name myems-api myems/myems-api
docker run -d -p 8000:8000 -v c:\myems-upload:/var/www/myems-admin/upload -v c:\myems-api\.env:/code/.env --restart always --name myems-api myems/myems-api
```
On Linux host, bind-mount a share upload file folder at /myems-upload to the container,
and also bind-mount the .env to the container:
```bash
docker run -d -p 8000:8000 -v /myems-upload:/var/www/html/admin/upload -v /myems-api/.env:/.env --restart always --name myems-api myems/myems-api
docker run -d -p 8000:8000 -v /myems-upload:/var/www/myems-admin/upload -v /myems-api/.env:/.env --restart always --name myems-api myems/myems-api
```
* -d Run container in background and print container ID

View File

@ -94,9 +94,9 @@ working_day_start_time_local = config('WORKING_DAY_START_TIME_LOCAL', default='0
# indicates where user uploaded files will be saved to
# must use the root folder of myems-admin web application
# for example if you serve myems-admin at /var/www/html/admin
# for example if you serve myems-admin at /var/www/myems-admin
# you should set the upload_path as below
upload_path = config('UPLOAD_PATH', default='/var/www/html/admin/upload/')
upload_path = config('UPLOAD_PATH', default='/var/www/myems-admin/upload/')
# main currency unit
currency_unit = config('CURRENCY_UNIT', default='CNY')

View File

@ -81,9 +81,9 @@ WORKING_DAY_START_TIME_LOCAL=00:00:00
# indicates where user uploaded files will be saved to
# must use the root folder of myems-admin web application
# for example if you serve myems-admin at /var/www/html/admin
# for example if you serve myems-admin at /var/www/myems-admin
# you should set the upload_path as below
UPLOAD_PATH=/var/www/html/admin/upload/
UPLOAD_PATH=/var/www/myems-admin/upload/
# main currency unit
CURRENCY_UNIT=CNY

View File

@ -11,9 +11,9 @@ $ xcode-select --install
然后安装python3
```shell
$ brew search python3 //默认安装最新版3.9
$ brew search python3 //默认安装最新版3.10
$ python3 -V
Python 3.9.1 //安装Python3 OK
Python 3.10.1 //安装Python3 OK
```
国内网络可能会出现安装慢的问题,配置下国内的资源镜像
```shell
@ -45,18 +45,20 @@ Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
```
然后初始化数据库,克隆[myems-database](https://github.com/myems/myems-database)到本地。
然后初始化数据库,克隆[myems](https://github.com/myems/myems)到本地。
```shell
$ git clone https://github.com/myems/myems-database.git
$ cd myems-database
$ git clone https://github.com/myems/myems.git
$ cd myems/myems-database
$ mysql -u root -p密码 //用root登录mysql
mysql>
source myems_billing_baseline_db.sql
source myems_billing_db.sql
source myems_carbon_db.sql
source myems_energy_baseline_db.sql
source myems_energy_db.sql
source myems_fdd_db.sql
source myems_historical_db.sql
source myems_production_db.sql
source myems_reporting_db.sql
source myems_system_db.sql
source myems_user_db.sql
@ -68,10 +70,12 @@ mysql> show databases; // 查看数据库是否导入OK
| information_schema |
| myems_billing_baseline_db |
| myems_billing_db |
| myems_carbon_db |
| myems_energy_baseline_db |
| myems_energy_db |
| myems_fdd_db |
| myems_historical_db |
| myems_production_db |
| myems_reporting_db |
| myems_system_db |
| myems_user_db |
@ -135,7 +139,6 @@ $ source ~/.zshrc
### 4.运行myems-api服务
```shell
$ git clone https://github.com/kuuyee/myems-api.git
$ cd myems/myems-api
$ gunicorn -b 0.0.0.0:8000 app:api
[2021-02-16 22:21:46 +0800] [3252] [INFO] Starting gunicorn 20.0.4
@ -149,11 +152,11 @@ $ gunicorn -b 0.0.0.0:8000 app:api
### 5.验证myems-api服务
打开浏览器访问[http://0.0.0.0:8000/version](http://0.0.0.0:8000/version)
如果看到如下输出就表示服务启动正常。
如果看到输出版本信息就表示服务启动正常。
```json
{
"version": "MyEMS 1.3.2",
"release-date": "2021-10-22",
"version": "MyEMS 1.8.2",
"release-date": "2022-03-16",
"website": "https://myems.io"
}
```

View File

@ -1,8 +1,8 @@
# myems-web
## Introduction
Web 用户界面,用于能源数据可视化
Providing Web UI for energy data visualization
Web用户界面用于MyEMS能源数据可视化
Web UI for MyEMS energy data visualization
## Prerequisites
@ -12,7 +12,7 @@ Node.js 17.0.0 or later
## Running in Local Environment for Development
* Install Node.js via binary archive on Linux
* Install Node.js via binary archive on Linux
Download Current Linux Binaries (x64) from https://nodejs.org/en/download/current/
```bash
@ -33,17 +33,19 @@ npm version
npx -v
```
* Download all the necessary dependencies into the node_modules directory.
* Download all the necessary dependencies into the node_modules directory.
```bash
cd myems/myems-web
npm i --unsafe-perm=true --allow-root --legacy-peer-deps
```
* If you modified any scss files then you need to compile SCSS, else you can safely ignore this step.
* If you modified any scss files then you need to compile SCSS, else you can safely ignore this step.
Run below command in your project directory to compile scss.
```bash
npm run scss
```
* Starting the Development Server
* Starting the Development Server
A local web server will start at http://localhost:3000.
We are using webpack and webpack-serve to automatically detect file changes. So, if you edit and save a file, your browser will automatically refresh and preview the change.
```bash
@ -173,21 +175,23 @@ Restart NGINX
sudo systemctl restart nginx
```
* Install MyEMS Web UI:
* Install MyEMS Web UI:
Check and change the config file if necessary:
Check and change the config file if necessary:
```bash
cd myems/myems-web
sudo nano src/config.js
```
Build and Compress
Build and Compress
```bash
sudo npm run build
tar czvf myems-web.tar.gz build
```
Install
Upload the file myems-web.tar.gz to you web server.
Note that the following path should be same as that was configured in nginx.conf.
Install
Upload the file myems-web.tar.gz to you web server.
Note that the following path should be same as that was configured in nginx.conf.
```bash
tar xzf myems-web.tar.gz
sudo rm -r /var/www/myems-web
@ -195,11 +199,11 @@ sudo mv build /var/www/myems-web
```
### Option 3: Install on Apache2 Server
* Install Apache2 Server
* Install Apache2 Server
refer to https://httpd.apache.org/docs/2.4/install.html
* Configure Apache2
* Configure Apache2
```bash
sudo vi /etc/apache2/ports.conf
```
@ -226,22 +230,24 @@ Add a new 'VirtualHost' as below
</VirtualHost>
```
* Install MyEMS Web UI:
* Install MyEMS Web UI:
Check and change the config file if necessary:
Check and change the config file if necessary:
```bash
cd myems/myems-web
sudo nano src/config.js
```
Build and Compress
Build and Compress
```bash
cd myems/myems-web/
sudo npm run build
tar czvf myems-web.tar.gz build
```
Install
Upload the file myems-web.tar.gz to you web server.
Note that the following path should be same as that was configured in 000-default.conf
Install
Upload the file myems-web.tar.gz to you web server.
Note that the following path should be same as that was configured in 000-default.conf
```bash
tar xzf myems-web.tar.gz
sudo rm -r /var/www/myems-web
@ -274,13 +280,15 @@ LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
```
### Option 4: Install myems-web on Node.js Web Server
* Run below command in your project directory to make the Production build.
This will create an optimized production build by compililing, merging and minifying all the source files as necessary and put them in the build/ folder.
* Run below command in your project directory to make the Production build.
This will create an optimized production build by compiling, merging and minifying all the source files as necessary and put them in the build/ folder.
```bash
sudo npm run build
```
* Run the production build locally at http://localhost:80.
* Run the production build locally at http://localhost:80.
If you want to listen on other port, change it in myems/myems-web/server.js
```
```bash
sudo node server.js
```