Skip to content

Commit

Permalink
默认配置文件由 config.json 变为 config.example.json (chen310#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
chen310 authored Mar 11, 2022
1 parent ff61d84 commit 6fd353f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __pycache__/
*test.py
.env
Myconfig.json
config.json
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,24 +624,54 @@ ql repo https://github.com/chen310/NeteaseCloudMusicTasks.git "index.py" "" "py"

### 下载

拉取代码

```shell
git clone https://github.com/chen310/NeteaseCloudMusicTasks.git
```

### 安装依赖

切换到项目目录

```shell
cd NeteaseCloudMusicTasks
```

然后安装依赖

```shell
pip install -r requirements.txt
```

### 修改配置文件

对配置文件 `config.json` 进行修改
首先将 `config.example.json` 文件复制为 `config.json` 文件

```shell
cp config.example.json config.json
```

然后对配置文件 `config.json` 进行修改。

### 运行

```shell
python index.py
python3 index.py
```

### 更新代码

首先更新代码

```shell
git pull
```

然后更新配置文件

```shell
python3 ./serverless/loadconfig.py config.example.json config.json config.json
```

## 四、使用`docker`部署
Expand All @@ -653,7 +683,7 @@ python index.py
### 下载并配置 `config.json`

```shell
curl -fsSL -o config.json https://raw.githubusercontent.com/chen310/NeteaseCloudMusicTasks/main/config.json
curl -fsSL -o config.json https://raw.githubusercontent.com/chen310/NeteaseCloudMusicTasks/main/config.example.json
```

### 随机时间执行
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ql_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
scripts_config = data_path + 'scripts/chen310_NeteaseCloudMusicTasks/config.json'
old_config = data_path + 'scripts/chen310_NeteaseCloudMusicTasks/config.old.json'
example_config = data_path + 'scripts/chen310_NeteaseCloudMusicTasks/config.example.json'
repo_config = data_path + 'repo/chen310_NeteaseCloudMusicTasks/config.json'
repo_config = data_path + 'repo/chen310_NeteaseCloudMusicTasks/config.example.json'
dependencies = data_path + 'repo/chen310_NeteaseCloudMusicTasks/requirements.txt'
if os.path.exists(scripts_config):
print('备份配置文件...')
Expand Down
17 changes: 10 additions & 7 deletions serverless/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if [ -z "$TENCENT_SECRET_ID" ] || [ -z "$TENCENT_SECRET_KEY" ]; then
echo "请配置SECRET_ID和SECRET_KEY两个secrets"
echo "请配置 SECRET_ID 和 SECRET_KEY 两个 secrets"
echo -e "\033[1;31m部署失败 \033[0m"
exit 1
fi
Expand All @@ -25,25 +25,28 @@ else
config_file="./config.json"
old_config_file="./config.old.json"
example_config_file="./config.example.json"
# 复制模板文件为配置文件
cp $example_config_file $config_file
if [ -e "./code/config.json" ]; then
sudo mv ./code/config.json $old_config_file
sudo cp $config_file $example_config_file
python ./serverless/loadconfig.py $config_file $old_config_file $config_file
# 备份配置文件
mv ./code/config.json $old_config_file
# 将旧配置文件中的数据转移到新配置文件中
python ./serverless/loadconfig.py $example_config_file $old_config_file $config_file
if [ $? -ne 0 ]; then
echo "配置文件复制错误,请检查config.json文件是否填写正确"
echo "配置文件复制错误,请检查 config.json 文件是否填写正确"
echo -e "\033[1;31m部署失败 \033[0m"
exit 1
fi
echo "已加载配置文件"
export DEPLOY_TYPE="update"
else
echo "配置文件不存在,请检查FUNCTION_NAME填写是否正确,避免覆盖其他函数"
echo "配置文件不存在,请检查 FUNCTION_NAME 填写是否正确,避免覆盖其他函数"
echo -e "\033[1;31m部署失败 \033[0m"
exit 1
fi
fi

echo "开始安装ServerlessFramework"
echo "开始安装 ServerlessFramework"
sudo npm install -g serverless >>/dev/null
sudo mkdir tmp/
shopt -s extglob
Expand Down

0 comments on commit 6fd353f

Please sign in to comment.