@wjwjq/release-helper 0.1.4 → 0.1.5

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.
@@ -182,10 +182,11 @@ chmod +x upgrade.sh
182
182
  | 安装目录 | /opt/$APP_NAME$/ |
183
183
  | 版本文件 | /opt/$APP_NAME$/version |
184
184
  | nginx配置文件 | /opt/$APP_NAME$/nginx/nginx.conf |
185
- | 日志文件位置 | /var/log/nginx/$APP_NAME$.log |
185
+ | 日志文件位置 | /var/log/$APP_NAME$/nginx.log |
186
186
  | 系统静态资源目录 | /opt/$APP_NAME$/assets/ |
187
187
  | 系统配置文件 | /opt/$APP_NAME$/assets/settings |
188
188
  | system service位置 | /usr/lib/systemd/system/$APP_NAME$.nginx.service |
189
+ | 日志翻转配置位置 | /etc/logrotate.d/$APP_NAME$.nginx |
189
190
 
190
191
  ## 4.2 启动命令
191
192
 
@@ -414,21 +415,4 @@ tar: Error is not recoverable: exiting now
414
415
 
415
416
  页面配置: **最新版配置文件,请查看最新版本$APP_NAME$.tar.gz解压路径"/$APP_NAME$/pkg/assets/settings"**
416
417
 
417
- nginx配置: **最新版配置文件,请查看最新版本$APP_NAME$.tar.gz解压路径"/$APP_NAME$/pkg/nginx/nginx.conf"**
418
-
419
- ## 5.1 v1.7.0
420
-
421
- 无变更, 无需手动修改
422
-
423
- ## 5.2 v1.8.0
424
-
425
- 新增配置项 安全事件返回条数限制
426
-
427
- ```text
428
- # 第5行
429
- systemSafeEventDate.limit=43200
430
- ````
431
-
432
- ## 5.3 v1.9.0
433
-
434
- 无变更, 无需手动修改
418
+ nginx配置: **最新版配置文件,请查看最新版本$APP_NAME$.tar.gz解压路径"/$APP_NAME$/pkg/nginx/nginx.conf"**
@@ -0,0 +1,14 @@
1
+ /var/log/__app_name__/*.log {
2
+ daily
3
+ missingok
4
+ minsize 100M
5
+ rotate 3
6
+ compress
7
+ delaycompress
8
+ notifempty
9
+ create 0644 __user__ __usergroup__
10
+ sharedscripts
11
+ postrotate
12
+ [ -f __pid_file__ ] && kill -USR1 `cat __pid_file__`
13
+ endscript
14
+ }
@@ -181,6 +181,7 @@ start() {
181
181
 
182
182
  copy_nginx_conf_and_write_verison
183
183
  add_nginx_service
184
+ add_log_rotate
184
185
  install_assets
185
186
 
186
187
  # 修改所属用户
@@ -14,32 +14,26 @@ nginx_conf_install_path="$prefix/opt/${app_name}/nginx/"
14
14
  nginx_conf_path="${nginx_conf_install_path}nginx.conf"
15
15
 
16
16
  # asset_path="$prefix/opt/posidon-frontend/"
17
- nginx_log_path="/var/log/nginx"
18
- nginx_log_file="${app_name}.nginx.log"
17
+ nginx_info_path="/var/log/${app_name}"
18
+ nginx_log_file="nginx.log"
19
19
  #不放在var/run 是因为重启后 var/run/下面的文件及目录会被清除
20
- nginx_pid_dir="/var/log/nginx/"
21
- nginx_pid_file_path="$nginx_pid_dir${app_name}.nginx.pid"
20
+ nginx_pid_file_path="$nginx_info_path/nginx.pid"
22
21
 
23
22
  conf_version=$(awk '{print $1}' "${pkg_path}"/version)
24
23
  echo "$conf_version"
25
24
 
26
25
  copy_nginx_conf_and_write_verison() {
27
26
  mkdir -p "$nginx_conf_install_path"
28
- # 创建pid目录
29
- mkdir -p $nginx_pid_dir
30
- chown -R $user:$usergroup $nginx_pid_dir
31
- chmod 744 -R $nginx_pid_dir
32
-
33
- # 创建日志目录
34
- mkdir -p $nginx_log_path
35
- touch $nginx_log_path/$nginx_log_file
36
- chown -R $user:$usergroup $nginx_log_path
37
- chmod 744 -R $nginx_log_path
27
+ # 创建pid目录. 创建日志目录
28
+ mkdir -p $nginx_info_path
29
+ touch $nginx_info_path/$nginx_log_file
30
+ chown -R $user:$usergroup $nginx_info_path
31
+ chmod 744 -R $nginx_info_path
38
32
 
39
33
  access_log_super="access_log /dev/stdout main"
40
34
  error_log_super="error_log /dev/stderr warn"
41
- access_log="access_log $nginx_log_path/$nginx_log_file main"
42
- error_log="error_log $nginx_log_path/$nginx_log_file"
35
+ access_log="access_log $nginx_info_path/$nginx_log_file main"
36
+ error_log="error_log $nginx_info_path/$nginx_log_file"
43
37
  pid_file="pid $nginx_pid_file_path"
44
38
 
45
39
  exec=$(get_exec_path)
@@ -145,16 +139,16 @@ get_exec_cmd() {
145
139
 
146
140
  add_nginx_service() {
147
141
  #添加到服务
148
- exec_cmd="$(get_exec_cmd) -e $nginx_log_path/$nginx_log_file"
142
+ exec_cmd="$(get_exec_cmd) -e $nginx_info_path/$nginx_log_file"
149
143
  cp "$pkg_path"/nginx/nginx.service.tpl ./nginx.service
150
144
 
151
- check_cmd="$exec -t -c $nginx_conf_path -e $nginx_log_path/$nginx_log_file"
145
+ check_cmd="$exec -t -c $nginx_conf_path -e $nginx_info_path/$nginx_log_file"
152
146
  version=$(echo "$conf_version" | grep -oP '\d+\.\d+\.\d+')
153
147
 
154
148
  sed -i "s#_user_group_#$usergroup#g" ./nginx.service
155
149
  sed -i "s#_user_#$user#g" ./nginx.service
156
150
  sed -i "s#_exec_cmd_#$exec_cmd #g" ./nginx.service
157
- sed -i "s#_log_path_#$nginx_log_path#g" ./nginx.service
151
+ sed -i "s#_log_path_#$nginx_info_path#g" ./nginx.service
158
152
  sed -i "s#_log_file_#$nginx_log_file#g" ./nginx.service
159
153
  sed -i "s#_conf_path_#$nginx_conf_path#g" ./nginx.service
160
154
  sed -i "s#_version_#$version#g" ./nginx.service
@@ -171,6 +165,21 @@ add_nginx_service() {
171
165
  rm -rf /usr/lib/systemd/system/"$app_name".nginx.service
172
166
  fi
173
167
  }
168
+
169
+ add_log_rotate(){
170
+ mkdir -p /etc/logrotate.d
171
+
172
+ rm -rf /etc/logrotate.d/${app_name}.nginx
173
+ #添加日志翻转
174
+ cp "$pkg_path"/nginx/nginx.logrotate.tpl ./nginx.logrotate
175
+
176
+ sed -i "s#__usergroup__#$usergroup#g" ./nginx.logrotate
177
+ sed -i "s#__user__#$user#g" ./nginx.logrotate
178
+ sed -i "s#__app_name__#$app_name#g" ./nginx.logrotate
179
+ sed -i "s#__pid_file__#$nginx_pid_file_path#g" ./nginx.logrotate
180
+
181
+ cp -f ./nginx.logrotate /etc/logrotate.d/${app_name}.nginx
182
+ }
174
183
  #------------------------------------ nginx服务配置文件服务 end----------------------------------
175
184
 
176
185
 
@@ -247,7 +256,7 @@ install_nginx_binary() {
247
256
  log_error "nginx installation failed!"
248
257
  fi
249
258
 
250
- cp "$nginx_binary_install_path"sbin/nginx /usr/sbin/
259
+ ln -sf "$nginx_binary_install_path"sbin/nginx /usr/sbin/nginx
251
260
 
252
261
  # 修改/etc/nginx 用户(组)
253
262
  chown -R $user:$usergroup "$nginx_binary_install_path"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wjwjq/release-helper",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "generate deployment package for frontend, include nginx...",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -63,7 +63,7 @@
63
63
  "node": "^18.20.0 || >=20.0.0"
64
64
  },
65
65
  "scripts": {
66
- "localpack": "pnpm link --global",
66
+ "localpack": "pnpm build && pnpm link --global",
67
67
  "postinstall": "node dist/start_prepare.js",
68
68
  "build": "rm -rf dist && rollup -c",
69
69
  "prepublish": "pnpm build"
@@ -182,10 +182,11 @@ chmod +x upgrade.sh
182
182
  | 安装目录 | /opt/$APP_NAME$/ |
183
183
  | 版本文件 | /opt/$APP_NAME$/version |
184
184
  | nginx配置文件 | /opt/$APP_NAME$/nginx/nginx.conf |
185
- | 日志文件位置 | /var/log/nginx/$APP_NAME$.log |
185
+ | 日志文件位置 | /var/log/$APP_NAME$/nginx.log |
186
186
  | 系统静态资源目录 | /opt/$APP_NAME$/assets/ |
187
187
  | 系统配置文件 | /opt/$APP_NAME$/assets/settings |
188
188
  | system service位置 | /usr/lib/systemd/system/$APP_NAME$.nginx.service |
189
+ | 日志翻转配置位置 | /etc/logrotate.d/$APP_NAME$.nginx |
189
190
 
190
191
  ## 4.2 启动命令
191
192
 
@@ -414,21 +415,4 @@ tar: Error is not recoverable: exiting now
414
415
 
415
416
  页面配置: **最新版配置文件,请查看最新版本$APP_NAME$.tar.gz解压路径"/$APP_NAME$/pkg/assets/settings"**
416
417
 
417
- nginx配置: **最新版配置文件,请查看最新版本$APP_NAME$.tar.gz解压路径"/$APP_NAME$/pkg/nginx/nginx.conf"**
418
-
419
- ## 5.1 v1.7.0
420
-
421
- 无变更, 无需手动修改
422
-
423
- ## 5.2 v1.8.0
424
-
425
- 新增配置项 安全事件返回条数限制
426
-
427
- ```text
428
- # 第5行
429
- systemSafeEventDate.limit=43200
430
- ````
431
-
432
- ## 5.3 v1.9.0
433
-
434
- 无变更, 无需手动修改
418
+ nginx配置: **最新版配置文件,请查看最新版本$APP_NAME$.tar.gz解压路径"/$APP_NAME$/pkg/nginx/nginx.conf"**
@@ -0,0 +1,14 @@
1
+ /var/log/__app_name__/*.log {
2
+ daily
3
+ missingok
4
+ minsize 100M
5
+ rotate 3
6
+ compress
7
+ delaycompress
8
+ notifempty
9
+ create 0644 __user__ __usergroup__
10
+ sharedscripts
11
+ postrotate
12
+ [ -f __pid_file__ ] && kill -USR1 `cat __pid_file__`
13
+ endscript
14
+ }
@@ -181,6 +181,7 @@ start() {
181
181
 
182
182
  copy_nginx_conf_and_write_verison
183
183
  add_nginx_service
184
+ add_log_rotate
184
185
  install_assets
185
186
 
186
187
  # 修改所属用户
@@ -14,32 +14,26 @@ nginx_conf_install_path="$prefix/opt/${app_name}/nginx/"
14
14
  nginx_conf_path="${nginx_conf_install_path}nginx.conf"
15
15
 
16
16
  # asset_path="$prefix/opt/posidon-frontend/"
17
- nginx_log_path="/var/log/nginx"
18
- nginx_log_file="${app_name}.nginx.log"
17
+ nginx_info_path="/var/log/${app_name}"
18
+ nginx_log_file="nginx.log"
19
19
  #不放在var/run 是因为重启后 var/run/下面的文件及目录会被清除
20
- nginx_pid_dir="/var/log/nginx/"
21
- nginx_pid_file_path="$nginx_pid_dir${app_name}.nginx.pid"
20
+ nginx_pid_file_path="$nginx_info_path/nginx.pid"
22
21
 
23
22
  conf_version=$(awk '{print $1}' "${pkg_path}"/version)
24
23
  echo "$conf_version"
25
24
 
26
25
  copy_nginx_conf_and_write_verison() {
27
26
  mkdir -p "$nginx_conf_install_path"
28
- # 创建pid目录
29
- mkdir -p $nginx_pid_dir
30
- chown -R $user:$usergroup $nginx_pid_dir
31
- chmod 744 -R $nginx_pid_dir
32
-
33
- # 创建日志目录
34
- mkdir -p $nginx_log_path
35
- touch $nginx_log_path/$nginx_log_file
36
- chown -R $user:$usergroup $nginx_log_path
37
- chmod 744 -R $nginx_log_path
27
+ # 创建pid目录. 创建日志目录
28
+ mkdir -p $nginx_info_path
29
+ touch $nginx_info_path/$nginx_log_file
30
+ chown -R $user:$usergroup $nginx_info_path
31
+ chmod 744 -R $nginx_info_path
38
32
 
39
33
  access_log_super="access_log /dev/stdout main"
40
34
  error_log_super="error_log /dev/stderr warn"
41
- access_log="access_log $nginx_log_path/$nginx_log_file main"
42
- error_log="error_log $nginx_log_path/$nginx_log_file"
35
+ access_log="access_log $nginx_info_path/$nginx_log_file main"
36
+ error_log="error_log $nginx_info_path/$nginx_log_file"
43
37
  pid_file="pid $nginx_pid_file_path"
44
38
 
45
39
  exec=$(get_exec_path)
@@ -145,16 +139,16 @@ get_exec_cmd() {
145
139
 
146
140
  add_nginx_service() {
147
141
  #添加到服务
148
- exec_cmd="$(get_exec_cmd) -e $nginx_log_path/$nginx_log_file"
142
+ exec_cmd="$(get_exec_cmd) -e $nginx_info_path/$nginx_log_file"
149
143
  cp "$pkg_path"/nginx/nginx.service.tpl ./nginx.service
150
144
 
151
- check_cmd="$exec -t -c $nginx_conf_path -e $nginx_log_path/$nginx_log_file"
145
+ check_cmd="$exec -t -c $nginx_conf_path -e $nginx_info_path/$nginx_log_file"
152
146
  version=$(echo "$conf_version" | grep -oP '\d+\.\d+\.\d+')
153
147
 
154
148
  sed -i "s#_user_group_#$usergroup#g" ./nginx.service
155
149
  sed -i "s#_user_#$user#g" ./nginx.service
156
150
  sed -i "s#_exec_cmd_#$exec_cmd #g" ./nginx.service
157
- sed -i "s#_log_path_#$nginx_log_path#g" ./nginx.service
151
+ sed -i "s#_log_path_#$nginx_info_path#g" ./nginx.service
158
152
  sed -i "s#_log_file_#$nginx_log_file#g" ./nginx.service
159
153
  sed -i "s#_conf_path_#$nginx_conf_path#g" ./nginx.service
160
154
  sed -i "s#_version_#$version#g" ./nginx.service
@@ -171,6 +165,21 @@ add_nginx_service() {
171
165
  rm -rf /usr/lib/systemd/system/"$app_name".nginx.service
172
166
  fi
173
167
  }
168
+
169
+ add_log_rotate(){
170
+ mkdir -p /etc/logrotate.d
171
+
172
+ rm -rf /etc/logrotate.d/${app_name}.nginx
173
+ #添加日志翻转
174
+ cp "$pkg_path"/nginx/nginx.logrotate.tpl ./nginx.logrotate
175
+
176
+ sed -i "s#__usergroup__#$usergroup#g" ./nginx.logrotate
177
+ sed -i "s#__user__#$user#g" ./nginx.logrotate
178
+ sed -i "s#__app_name__#$app_name#g" ./nginx.logrotate
179
+ sed -i "s#__pid_file__#$nginx_pid_file_path#g" ./nginx.logrotate
180
+
181
+ cp -f ./nginx.logrotate /etc/logrotate.d/${app_name}.nginx
182
+ }
174
183
  #------------------------------------ nginx服务配置文件服务 end----------------------------------
175
184
 
176
185
 
@@ -247,7 +256,7 @@ install_nginx_binary() {
247
256
  log_error "nginx installation failed!"
248
257
  fi
249
258
 
250
- cp "$nginx_binary_install_path"sbin/nginx /usr/sbin/
259
+ ln -sf "$nginx_binary_install_path"sbin/nginx /usr/sbin/nginx
251
260
 
252
261
  # 修改/etc/nginx 用户(组)
253
262
  chown -R $user:$usergroup "$nginx_binary_install_path"