yourtar-cli 1.3.3 → 2.0.0
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.
- package/bin/backTemplate/Makefile +7 -0
- package/bin/backTemplate/config/packages/monolog.yaml +61 -0
- package/bin/backTemplate/docker/config/promtail/config.yml +18 -0
- package/bin/backTemplate/docker/docker-compose.prod.yml +11 -0
- package/bin/backTemplate/docker/docker-compose.stage.yml +11 -0
- package/bin/backTemplate/src/Logging/YTExtraDataProcessor.php +20 -0
- package/bin/botTemplate/.env.dev-example +3 -1
- package/bin/botTemplate/.env.prod-example +3 -1
- package/bin/botTemplate/.env.stage-example +3 -1
- package/bin/botTemplate/Makefile +21 -2
- package/bin/botTemplate/config/packages/monolog.yaml +61 -0
- package/bin/botTemplate/docker/config/promtail/config.yml +18 -0
- package/bin/botTemplate/docker/docker-compose.prod.yml +11 -0
- package/bin/botTemplate/docker/docker-compose.stage.yml +11 -0
- package/bin/botTemplate/src/Logging/YTExtraDataProcessor.php +20 -0
- package/bin/index.js +2 -2
- package/package.json +1 -1
|
@@ -25,5 +25,12 @@ down:
|
|
|
25
25
|
shell:
|
|
26
26
|
cd docker && docker compose -f docker-compose.${APP_MODE}.yml run php_{{name}}_back bash
|
|
27
27
|
|
|
28
|
+
update:
|
|
29
|
+
make down
|
|
30
|
+
git pull
|
|
31
|
+
make up
|
|
32
|
+
sudo chmod -R 777 var/ public/
|
|
33
|
+
make -C ~/gateway restart
|
|
34
|
+
|
|
28
35
|
database:
|
|
29
36
|
cd docker && docker compose -f docker-compose.${APP_MODE}.yml exec mysql_{{name}}_back mysql -uroot -p$(DATABASE_PASSWORD)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
monolog:
|
|
2
|
+
channels:
|
|
3
|
+
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
|
|
4
|
+
- {{name}}
|
|
5
|
+
|
|
6
|
+
when@dev:
|
|
7
|
+
monolog:
|
|
8
|
+
handlers:
|
|
9
|
+
main:
|
|
10
|
+
type: stream
|
|
11
|
+
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
|
12
|
+
level: debug
|
|
13
|
+
channels: ["!event"]
|
|
14
|
+
# uncomment to get logging in your browser
|
|
15
|
+
# you may have to allow bigger header sizes in your Web server configuration
|
|
16
|
+
#firephp:
|
|
17
|
+
# type: firephp
|
|
18
|
+
# level: info
|
|
19
|
+
#chromephp:
|
|
20
|
+
# type: chromephp
|
|
21
|
+
# level: info
|
|
22
|
+
console:
|
|
23
|
+
type: console
|
|
24
|
+
process_psr_3_messages: false
|
|
25
|
+
channels: ["!event", "!doctrine", "!console"]
|
|
26
|
+
|
|
27
|
+
when@test:
|
|
28
|
+
monolog:
|
|
29
|
+
handlers:
|
|
30
|
+
main:
|
|
31
|
+
type: fingers_crossed
|
|
32
|
+
action_level: error
|
|
33
|
+
handler: nested
|
|
34
|
+
excluded_http_codes: [404, 405]
|
|
35
|
+
channels: ["!event"]
|
|
36
|
+
nested:
|
|
37
|
+
type: stream
|
|
38
|
+
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
|
39
|
+
level: debug
|
|
40
|
+
|
|
41
|
+
when@prod:
|
|
42
|
+
monolog:
|
|
43
|
+
handlers:
|
|
44
|
+
main:
|
|
45
|
+
type: stream
|
|
46
|
+
action_level: error
|
|
47
|
+
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
|
48
|
+
level: error
|
|
49
|
+
channels: ["!event", "{{name}}"]
|
|
50
|
+
service_name: "{{name}}"
|
|
51
|
+
formatter: monolog.formatter.json
|
|
52
|
+
console:
|
|
53
|
+
type: console
|
|
54
|
+
process_psr_3_messages: false
|
|
55
|
+
channels: ["!event", "!doctrine"]
|
|
56
|
+
formatter: monolog.formatter.json
|
|
57
|
+
deprecation:
|
|
58
|
+
type: stream
|
|
59
|
+
channels: [deprecation]
|
|
60
|
+
path: php://stderr
|
|
61
|
+
formatter: monolog.formatter.json
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
server:
|
|
2
|
+
http_listen_port: 9080
|
|
3
|
+
grpc_listen_port: 0
|
|
4
|
+
|
|
5
|
+
positions:
|
|
6
|
+
filename: /tmp/positions.yaml
|
|
7
|
+
|
|
8
|
+
clients:
|
|
9
|
+
- url: http://monitor.inf.yourtar.ru:3100/loki/api/v1/push
|
|
10
|
+
|
|
11
|
+
scrape_configs:
|
|
12
|
+
- job_name: system
|
|
13
|
+
static_configs:
|
|
14
|
+
- targets:
|
|
15
|
+
- localhost
|
|
16
|
+
labels:
|
|
17
|
+
job: varlogs
|
|
18
|
+
__path__: /var/log/*log
|
|
@@ -82,6 +82,17 @@ services:
|
|
|
82
82
|
# - {{name}}
|
|
83
83
|
# restart: on-failure
|
|
84
84
|
|
|
85
|
+
# promtail_{{name}}:
|
|
86
|
+
# image: grafana/promtail:latest
|
|
87
|
+
# container_name: promtail_{{name}}
|
|
88
|
+
# restart: unless-stopped
|
|
89
|
+
# environment:
|
|
90
|
+
# TZ: "Europe/Moscow"
|
|
91
|
+
# volumes:
|
|
92
|
+
# - ../var/log:/var/log
|
|
93
|
+
# - ./config/promtail/config.yml:/etc/promtail/config.yml
|
|
94
|
+
# command: -config.file=/etc/promtail/config.yml
|
|
95
|
+
|
|
85
96
|
networks:
|
|
86
97
|
yourtar:
|
|
87
98
|
external:
|
|
@@ -77,6 +77,17 @@ services:
|
|
|
77
77
|
# networks:
|
|
78
78
|
# - demo
|
|
79
79
|
|
|
80
|
+
# promtail_{{name}}:
|
|
81
|
+
# image: grafana/promtail:latest
|
|
82
|
+
# container_name: promtail_{{name}}
|
|
83
|
+
# restart: unless-stopped
|
|
84
|
+
# environment:
|
|
85
|
+
# TZ: "Europe/Moscow"
|
|
86
|
+
# volumes:
|
|
87
|
+
# - ../var/log:/var/log
|
|
88
|
+
# - ./config/promtail/config.yml:/etc/promtail/config.yml
|
|
89
|
+
# command: -config.file=/etc/promtail/config.yml
|
|
90
|
+
|
|
80
91
|
networks:
|
|
81
92
|
demo:
|
|
82
93
|
external: true
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace App\Logging;
|
|
4
|
+
|
|
5
|
+
use Monolog\Attribute\AsMonologProcessor;
|
|
6
|
+
use Monolog\LogRecord;
|
|
7
|
+
use Monolog\Processor\ProcessorInterface;
|
|
8
|
+
|
|
9
|
+
#[AsMonologProcessor]
|
|
10
|
+
class YTExtraDataProcessor implements ProcessorInterface
|
|
11
|
+
{
|
|
12
|
+
public function __invoke(LogRecord $record): LogRecord
|
|
13
|
+
{
|
|
14
|
+
// Add data to the 'extra' array
|
|
15
|
+
$record->extra['yourtar_log'] = true;
|
|
16
|
+
$record->extra['project'] = '{{name}}';
|
|
17
|
+
|
|
18
|
+
return $record;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -19,5 +19,7 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
|
|
|
19
19
|
DEFAULT_URI="http://localhost:8000"
|
|
20
20
|
|
|
21
21
|
###> Bot ###
|
|
22
|
-
|
|
22
|
+
#TG_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
23
|
+
#VK_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
24
|
+
#MAX_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
23
25
|
###< Bot ###
|
|
@@ -19,5 +19,7 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
|
|
|
19
19
|
DEFAULT_URI="http://localhost:8000"
|
|
20
20
|
|
|
21
21
|
###> Bot ###
|
|
22
|
-
|
|
22
|
+
#TG_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
23
|
+
#VK_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
24
|
+
#MAX_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
23
25
|
###< Bot ###
|
|
@@ -19,5 +19,7 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
|
|
|
19
19
|
DEFAULT_URI="http://localhost:8000"
|
|
20
20
|
|
|
21
21
|
###> Bot ###
|
|
22
|
-
|
|
22
|
+
#TG_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
23
|
+
#VK_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
24
|
+
#MAX_TOKEN=475749278:AAGxVLFFGiuymbuQYz-oHF_OoOIZhyxClA4
|
|
23
25
|
###< Bot ###
|
package/bin/botTemplate/Makefile
CHANGED
|
@@ -18,13 +18,22 @@ else
|
|
|
18
18
|
endif
|
|
19
19
|
cd docker && docker compose -f docker-compose.${APP_MODE}.yml exec php_{{name}}_back bin/console doctrine:database:create --if-not-exists
|
|
20
20
|
cd docker && docker compose -f docker-compose.${APP_MODE}.yml exec php_{{name}}_back bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
|
|
21
|
+
make webhook
|
|
21
22
|
|
|
22
23
|
down:
|
|
23
24
|
cd docker && docker compose -f docker-compose.${APP_MODE}.yml down
|
|
25
|
+
make webhook-delete
|
|
24
26
|
|
|
25
27
|
shell:
|
|
26
28
|
cd docker && docker compose -f docker-compose.${APP_MODE}.yml run php_{{name}}_back bash
|
|
27
29
|
|
|
30
|
+
update:
|
|
31
|
+
make down
|
|
32
|
+
git pull
|
|
33
|
+
make up
|
|
34
|
+
sudo chmod -R 777 var/ public/
|
|
35
|
+
make -C ~/gateway restart
|
|
36
|
+
|
|
28
37
|
database:
|
|
29
38
|
cd docker && docker compose -f docker-compose.${APP_MODE}.yml exec mysql_{{name}}_back mysql -uroot -p$(DATABASE_PASSWORD)
|
|
30
39
|
|
|
@@ -32,7 +41,17 @@ commands:
|
|
|
32
41
|
curl -X POST -H "Content-Type: application/json" -d "{\"commands\":[{\"command\":\"help\",\"description\":\"Помощь\"}]}" https://api.telegram.org/bot$(BOT_TOKEN)/setMyCommands
|
|
33
42
|
|
|
34
43
|
webhook:
|
|
35
|
-
|
|
44
|
+
ifndef TG_TOKEN
|
|
45
|
+
curl https://api.telegram.org:443/bot$(TG_TOKEN)/setWebhook?url=$(DEFAULT_URI)/api/message/
|
|
46
|
+
endif
|
|
47
|
+
ifndef MAX_TOKEN
|
|
48
|
+
curl -X POST "https://platform-api.max.ru/subscriptions" -H "Authorization: $(MAX_TOKEN)" -H "Content-Type: application/json" -d '{"url": "$(DEFAULT_URI)/api/message/max","update_types": ["message_created", "bot_started", "message_callback"],"secret": "your_secret"}'
|
|
49
|
+
endif
|
|
36
50
|
|
|
37
51
|
webhook-delete:
|
|
38
|
-
|
|
52
|
+
ifndef TG_TOKEN
|
|
53
|
+
curl https://api.telegram.org:443/bot$(TG_TOKEN)/deleteWebhook
|
|
54
|
+
endif
|
|
55
|
+
ifndef MAX_TOKEN
|
|
56
|
+
curl -X DELETE "https://platform-api.max.ru/subscriptions?url=$(DEFAULT_URI)/api/message/max" -H "Authorization: $(MAX_TOKEN)"
|
|
57
|
+
endif
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
monolog:
|
|
2
|
+
channels:
|
|
3
|
+
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
|
|
4
|
+
- {{name}}
|
|
5
|
+
|
|
6
|
+
when@dev:
|
|
7
|
+
monolog:
|
|
8
|
+
handlers:
|
|
9
|
+
main:
|
|
10
|
+
type: stream
|
|
11
|
+
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
|
12
|
+
level: debug
|
|
13
|
+
channels: ["!event"]
|
|
14
|
+
# uncomment to get logging in your browser
|
|
15
|
+
# you may have to allow bigger header sizes in your Web server configuration
|
|
16
|
+
#firephp:
|
|
17
|
+
# type: firephp
|
|
18
|
+
# level: info
|
|
19
|
+
#chromephp:
|
|
20
|
+
# type: chromephp
|
|
21
|
+
# level: info
|
|
22
|
+
console:
|
|
23
|
+
type: console
|
|
24
|
+
process_psr_3_messages: false
|
|
25
|
+
channels: ["!event", "!doctrine", "!console"]
|
|
26
|
+
|
|
27
|
+
when@test:
|
|
28
|
+
monolog:
|
|
29
|
+
handlers:
|
|
30
|
+
main:
|
|
31
|
+
type: fingers_crossed
|
|
32
|
+
action_level: error
|
|
33
|
+
handler: nested
|
|
34
|
+
excluded_http_codes: [404, 405]
|
|
35
|
+
channels: ["!event"]
|
|
36
|
+
nested:
|
|
37
|
+
type: stream
|
|
38
|
+
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
|
39
|
+
level: debug
|
|
40
|
+
|
|
41
|
+
when@prod:
|
|
42
|
+
monolog:
|
|
43
|
+
handlers:
|
|
44
|
+
main:
|
|
45
|
+
type: stream
|
|
46
|
+
action_level: error
|
|
47
|
+
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
|
48
|
+
level: error
|
|
49
|
+
channels: ["!event", "{{name}}"]
|
|
50
|
+
service_name: "{{name}}"
|
|
51
|
+
formatter: monolog.formatter.json
|
|
52
|
+
console:
|
|
53
|
+
type: console
|
|
54
|
+
process_psr_3_messages: false
|
|
55
|
+
channels: ["!event", "!doctrine"]
|
|
56
|
+
formatter: monolog.formatter.json
|
|
57
|
+
deprecation:
|
|
58
|
+
type: stream
|
|
59
|
+
channels: [deprecation]
|
|
60
|
+
path: php://stderr
|
|
61
|
+
formatter: monolog.formatter.json
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
server:
|
|
2
|
+
http_listen_port: 9080
|
|
3
|
+
grpc_listen_port: 0
|
|
4
|
+
|
|
5
|
+
positions:
|
|
6
|
+
filename: /tmp/positions.yaml
|
|
7
|
+
|
|
8
|
+
clients:
|
|
9
|
+
- url: http://monitor.inf.yourtar.ru:3100/loki/api/v1/push
|
|
10
|
+
|
|
11
|
+
scrape_configs:
|
|
12
|
+
- job_name: system
|
|
13
|
+
static_configs:
|
|
14
|
+
- targets:
|
|
15
|
+
- localhost
|
|
16
|
+
labels:
|
|
17
|
+
job: varlogs
|
|
18
|
+
__path__: /var/log/*log
|
|
@@ -82,6 +82,17 @@ services:
|
|
|
82
82
|
# - {{name}}
|
|
83
83
|
# restart: on-failure
|
|
84
84
|
|
|
85
|
+
# promtail_{{name}}:
|
|
86
|
+
# image: grafana/promtail:latest
|
|
87
|
+
# container_name: promtail_{{name}}
|
|
88
|
+
# restart: unless-stopped
|
|
89
|
+
# environment:
|
|
90
|
+
# TZ: "Europe/Moscow"
|
|
91
|
+
# volumes:
|
|
92
|
+
# - ../var/log:/var/log
|
|
93
|
+
# - ./config/promtail/config.yml:/etc/promtail/config.yml
|
|
94
|
+
# command: -config.file=/etc/promtail/config.yml
|
|
95
|
+
|
|
85
96
|
networks:
|
|
86
97
|
yourtar:
|
|
87
98
|
external:
|
|
@@ -77,6 +77,17 @@ services:
|
|
|
77
77
|
# networks:
|
|
78
78
|
# - demo
|
|
79
79
|
|
|
80
|
+
# promtail_{{name}}:
|
|
81
|
+
# image: grafana/promtail:latest
|
|
82
|
+
# container_name: promtail_{{name}}
|
|
83
|
+
# restart: unless-stopped
|
|
84
|
+
# environment:
|
|
85
|
+
# TZ: "Europe/Moscow"
|
|
86
|
+
# volumes:
|
|
87
|
+
# - ../var/log:/var/log
|
|
88
|
+
# - ./config/promtail/config.yml:/etc/promtail/config.yml
|
|
89
|
+
# command: -config.file=/etc/promtail/config.yml
|
|
90
|
+
|
|
80
91
|
networks:
|
|
81
92
|
demo:
|
|
82
93
|
external: true
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace App\Logging;
|
|
4
|
+
|
|
5
|
+
use Monolog\Attribute\AsMonologProcessor;
|
|
6
|
+
use Monolog\LogRecord;
|
|
7
|
+
use Monolog\Processor\ProcessorInterface;
|
|
8
|
+
|
|
9
|
+
#[AsMonologProcessor]
|
|
10
|
+
class YTExtraDataProcessor implements ProcessorInterface
|
|
11
|
+
{
|
|
12
|
+
public function __invoke(LogRecord $record): LogRecord
|
|
13
|
+
{
|
|
14
|
+
// Add data to the 'extra' array
|
|
15
|
+
$record->extra['yourtar_log'] = true;
|
|
16
|
+
$record->extra['project'] = '{{name}}';
|
|
17
|
+
|
|
18
|
+
return $record;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/bin/index.js
CHANGED
|
@@ -73,7 +73,7 @@ programm.command('create')
|
|
|
73
73
|
await fs.renameSync('./' + projectFolder + '/.env-main', './' + projectFolder + '/.env');
|
|
74
74
|
await fs.copyFileSync('./' + projectFolder + '/.env', './' + projectFolder + '/docker/.env');
|
|
75
75
|
await exec('docker compose -f ./' + projectFolder + '/docker/docker-compose.dev.yml up -d --build');
|
|
76
|
-
await exec('cd ' + projectFolder + '/docker && docker compose -f docker-compose.dev.yml exec php_' + answers.name + '_back composer require serializer security cors orm');
|
|
76
|
+
await exec('cd ' + projectFolder + '/docker && docker compose -f docker-compose.dev.yml exec php_' + answers.name + '_back composer require serializer security cors orm monolog');
|
|
77
77
|
if (fs.existsSync('./' + projectFolder + '/compose.yaml')) fs.unlinkSync('./' + projectFolder + '/compose.yaml');
|
|
78
78
|
if (fs.existsSync('./' + projectFolder + '/compose.override.yaml')) fs.unlinkSync('./' + projectFolder + '/compose.override.yaml');
|
|
79
79
|
await exec('cd ' + projectFolder + '/docker && docker compose -f docker-compose.dev.yml exec php_' + answers.name + '_back composer require --dev symfony/maker-bundle');
|
|
@@ -85,7 +85,7 @@ programm.command('create')
|
|
|
85
85
|
await fs.renameSync('./' + projectFolder + '/.env-main', './' + projectFolder + '/.env');
|
|
86
86
|
await fs.copyFileSync('./' + projectFolder + '/.env', './' + projectFolder + '/docker/.env');
|
|
87
87
|
await exec('docker compose -f ./' + projectFolder + '/docker/docker-compose.dev.yml up -d --build');
|
|
88
|
-
await exec('cd ' + projectFolder + '/docker && docker compose -f docker-compose.dev.yml exec php_' + answers.name + '_back composer require serializer security cors orm');
|
|
88
|
+
await exec('cd ' + projectFolder + '/docker && docker compose -f docker-compose.dev.yml exec php_' + answers.name + '_back composer require serializer security cors orm monolog');
|
|
89
89
|
if (fs.existsSync('./' + projectFolder + '/compose.yaml')) fs.unlinkSync('./' + projectFolder + '/compose.yaml');
|
|
90
90
|
if (fs.existsSync('./' + projectFolder + '/compose.override.yaml')) fs.unlinkSync('./' + projectFolder + '/compose.override.yaml');
|
|
91
91
|
await exec('cd ' + projectFolder + '/docker && docker compose -f docker-compose.dev.yml exec php_' + answers.name + '_back composer require --dev symfony/maker-bundle');
|