Celery: supervisord

Celery: supervisord conf 1 2 3 4 5 6 7 8 9 10 11 12 [program:epm-tasks] directory=/home/ubuntu/projects/epm/web user=ubuntu command=/home/ubuntu/.anyenv/envs/pyenv/versions/coresys/bin/celery -A app worker -l INFO -f /home/ubuntu/projects/epm/logs/tasks.log autostart=true autorestart=true ;stdout_logfile=syslog ;stderr_logfile=syslog numprocs=1 startsecs=10 stopwaitsecs = 600 killasgroup=true -f オプションで指定すると user の所有権でファイル作成 stdout_logfile / stderr_logfile で指定するとsupervisord ユーザー(root)の所有権で作成 log rotation It seems that you are using supervisord to manage Celery processes and you want to rotate the log files for Celery on a daily basis. One way to do this is to use logrotate, a tool that can rotate and compress log files according to a configuration file². To use logrotate, you need to do the following steps: ...

2023年4月12日 · 2 分

Terraform

README tfenvのインストール 設定ファイルの作成 terraform init terraform plan terraform apply 設計運用 Terraform設計・運用のノウハウ ベストプラクティス antonbabenko/terraform-best-practices ファイル 内容 main.tf リソースを作成する(moduels, locals, data-sources) variables.tf main.tf で使われる変数 outputs.tf main.tf が作成したリソースの出力 1 % tree large-terraform large-terraform ├── README.md ├── modules │ └── network │ ├── main.tf │ ├── outputs.tf │ └── variables.tf ├── prod │ ├── main.tf │ ├── outputs.tf │ ├── terraform.tfvars │ └── variables.tf └── stage ├── main.tf ├── outputs.tf ├── terraform.tfvars └── variables.tf HCL (HCL is the HashiCorp configuration language.) https://github.com/hashicorp/hcl Terraform v0.12で変わるHCLの記述について コメント: ...

2021年6月12日 · 1 分

AWS: ECS

ECS オートスケーリング 記事 Fargate で Amazon ECS サービスの自動スケーリングを設定する方法を教えてください。 AWS FargateでAutoScaleを試してみる Terraform の設定 オートスケーリングの設定をTerraformで記述する例を以下に示します。この例では、CPU使用率に基づいてECS Fargateサービスのタスク数を自動的にスケーリングするように設定します。 必要なリソース TerraformでECSサービスのオートスケーリングを設定するには、以下のリソースを定義します。 aws_appautoscaling_target: スケーリングの対象となるECSサービスとタスク数を指定します。 aws_appautoscaling_policy: 実際のスケーリングロジック(CPU使用率、目標値など)を定義します。 aws_cloudwatch_metric_alarm: (オプション) 詳細な条件でスケーリングを制御する場合に使用します。ターゲット追跡スケーリングポリシーは内部でこれを生成するため、通常は明示的に定義する必要はありません。 Terraform コード例 以下のコードブロックは、aws_ecs_serviceリソースで定義されたECSサービスに対して、CPU使用率が50%になるようにタスク数を調整するオートスケーリング設定の例です。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 # ECSサービスを定義 (この例では、既存サービスを想定) # resource "aws_ecs_service" "main" { # name = "my-ecs-service" # ... # } # 1. オートスケーリングの対象を定義 resource "aws_appautoscaling_target" "ecs_target" { service_namespace = "ecs" resource_id = "service/my-cluster/my-ecs-service" # サービス名に合わせて変更 scalable_dimension = "ecs:service:DesiredCount" min_capacity = 1 # 最小タスク数 max_capacity = 10 # 最大タスク数 } # 2. ターゲット追跡スケーリングポリシーを定義 resource "aws_appautoscaling_policy" "cpu_scaling_policy" { name = "cpu-utilization-scaling-policy" service_namespace = "ecs" resource_id = aws_appautoscaling_target.ecs_target.resource_id scalable_dimension = aws_appautoscaling_target.ecs_target.scalable_dimension policy_type = "TargetTrackingScaling" target_tracking_scaling_policy_configuration { predefined_metric_specification { predefined_metric_type = "ECSServiceAverageCPUUtilization" } target_value = 50.0 # CPU使用率の目標値(%) scale_in_cooldown = 300 # スケールイン(タスク減少)のクールダウン期間(秒) scale_out_cooldown = 60 # スケールアウト(タスク増加)のクールダウン期間(秒) } } コードの解説 aws_appautoscaling_target: ...

2021年6月4日 · 1 分

Laravel: マイグレーション

Laravel マイグレーション Laravel マイグレーションを1つずつ戻す 1 $ php artisan migrate:rollback --step=1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 MySQL [mysite]> select * from migrations; +----+--------------------------------------------------------------+-------+ | id | migration | batch | +----+--------------------------------------------------------------+-------+ | 1 | 2014_10_12_000000_create_users_table | 1 | | 2 | 2014_10_12_100000_create_password_resets_table | 1 | | 3 | 2019_08_19_000000_create_failed_jobs_table | 1 | | 4 | 2019_12_14_000001_create_personal_access_tokens_table | 1 | | 5 | 2021_01_27_074301_create_sessions_table | 1 | | 6 | 2021_02_03_055949_create_products_table | 1 | | 7 | 2021_02_03_060047_create_news_table | 1 | | 8 | 2021_02_08_024947_create_credit_cards_table | 1 | | 9 | 2021_02_08_025236_create_licenses_table | 1 | | 10 | 2021_02_08_060434_create_orders_table | 1 | | 11 | 2021_02_18_124506_create_options_table | 1 | | 12 | 2021_03_10_093455_update_string_fields_to_text | 2 | | 13 | 2021_04_09_123358_add_users_deleted_at_field | 3 | | 14 | 2021_04_09_123459_add_licenses_subscription_cancelled_fields | 3 | +----+--------------------------------------------------------------+-------+ 14 rows in set (0.002 sec) 1 % php artisan migrate:rollback --step=1 ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > yes Rolling back: 2021_04_09_123459_add_licenses_subscription_cancelled_fields Rolled back: 2021_04_09_123459_add_licenses_subscription_cancelled_fields (165.69ms) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 MySQL [mysite]> select * from migrations; +----+-------------------------------------------------------+-------+ | id | migration | batch | +----+-------------------------------------------------------+-------+ | 1 | 2014_10_12_000000_create_users_table | 1 | | 2 | 2014_10_12_100000_create_password_resets_table | 1 | | 3 | 2019_08_19_000000_create_failed_jobs_table | 1 | | 4 | 2019_12_14_000001_create_personal_access_tokens_table | 1 | | 5 | 2021_01_27_074301_create_sessions_table | 1 | | 6 | 2021_02_03_055949_create_products_table | 1 | | 7 | 2021_02_03_060047_create_news_table | 1 | | 8 | 2021_02_08_024947_create_credit_cards_table | 1 | | 9 | 2021_02_08_025236_create_licenses_table | 1 | | 10 | 2021_02_08_060434_create_orders_table | 1 | | 11 | 2021_02_18_124506_create_options_table | 1 | | 12 | 2021_03_10_093455_update_string_fields_to_text | 2 | | 13 | 2021_04_09_123358_add_users_deleted_at_field | 3 | +----+-------------------------------------------------------+-------+ 13 rows in set (0.002 sec)

2021年5月17日 · 2 分

Python:Exception

Python: Exception Python Exceptions: An Introduction 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 try: # 処理 linux_interaction() except AssertionError as error: # 例外 print(error) else: ## 例外がない場合 try: with open('file.log') as file: read_data = file.read() except FileNotFoundError as fnf_error: print(fnf_error) finally: # 最後に必ず実行 print('Cleaning up, irrespective of any exceptions.') Python Exception Base Classes 組み込み例外 8.6. ユーザー定義例外

2021年5月14日 · 1 分

Django Simple Docker File

% tree . -I '__*|db*' . ├── Dockerfile ├── poetry.lock ├── pyproject.toml └── web ├── blogsite │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── manage.py └── pages ├── admin.py ├── apps.py ├── migrations ├── models.py ├── tests.py ├── urls.py └── views.py 4 directories, 14 files

2021年2月19日 · 1 分

Wordpress Plugin with WP-CLI

Wordpress Development Environment vim wp-cli.yml ./scaffold.bash sudo $(phpenv prefix)/sbin/php-fpm -y conf/php-fpm.conf sudo ln -s $PWD/conf/nginx.conf /etc/nginx/sites-enabled/your_wp_cname.conf sudo /etc/init.d/nginx start

2015年8月9日 · 1 分

CentOS

$ sudo yum install graphviz-python graphviz-devel $ pip install pygraphviz

2015年8月4日 · 1 分

Packer

Packer && Box-Cutter for Windows C:\Users\hdknr>vagrant --version Vagrant 1.7.4 C:\Users\hdknr>packer --version 0.8.2 C:\Users\hdknr>ver Microsoft Windows [Version 6.3.9600] C:\Users\hdknr\Documents\work>git clone https://github.com/boxcutter/centos.git Cloning into 'centos'... remote: Counting objects: 1100, done. remote: Compressing objects: 100% (6/6), done. Rreceiving objects: 92% (1012/1100), 108.0emote: Total 1100 (delta 1), reused 0 (delta 0), pack-reused 1093 00 KiB/s Receiving objects: 100% (1100/1100), 227.44 KiB | 196.00 KiB/s, done. Resolving deltas: 100% (749/749), done. Checking connectivity... done. C:\Users\hdknr\Documents\work>cd centos C:\Users\hdknr\Documents\work\centos>vim http\ks6.cfg C:\Users\hdknr\Documents\work\centos>git diff http\ks6.cfg diff --git a/http/ks7.cfg b/http/ks7.cfg index 434a369..16797b0 100644 --- a/http/ks7.cfg +++ b/http/ks7.cfg @@ -14,11 +14,11 @@ # > linux text ks=http://<your_ip>:8000/ks.cfg # Required settings -lang en_US.UTF-8 -keyboard us +lang ja_JP.UTF-8 +keyboard jp106 rootpw vagrant authconfig --enableshadow --enablemd5 -timezone UTC +timezone Asia/Tokyo # Optional settings install C:\Users\hdknr\Documents\work\centos>packer validate centos66.json Template validated successfully. C:\Users\hdknr\Documents\work\centos>packer build -only=virtualbox-iso centos66.json virtualbox-iso output will be in this color. ==> virtualbox-iso: Downloading or copying Guest additions virtualbox-iso: Downloading or copying: file:///C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso ==> virtualbox-iso: Downloading or copying ISO virtualbox-iso: Downloading or copying: file:///iso/CentOS-6.6-x86_64-bin-DVD1.iso virtualbox-iso: Error downloading: open iso/CentOS-6.6-x86_64-bin-DVD1.iso: The system cannot find the path specifie d. virtualbox-iso: Downloading or copying: http://mirrors.kernel.org/centos/6.6/isos/x86_64/CentOS-6.6-x86_64-bin-DVD1. iso virtualbox-iso: Download progress: 0% ... ==> virtualbox-iso: Starting HTTP server on port 8364 ==> virtualbox-iso: Creating virtual machine... ==> virtualbox-iso: Creating hard drive... ==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 2262) ==> virtualbox-iso: Executing custom VBoxManage commands... virtualbox-iso: Executing: modifyvm centos66 --memory 512 virtualbox-iso: Executing: modifyvm centos66 --cpus 1 ==> virtualbox-iso: Starting the virtual machine... ==> virtualbox-iso: Waiting 10s for boot... ==> virtualbox-iso: Typing the boot command... ==> virtualbox-iso: Waiting for SSH to become available... ==> virtualbox-iso: Uploading VirtualBox version info (4.3.30) ==> virtualbox-iso: Uploading VirtualBox guest additions ISO... ==> virtualbox-iso: Provisioning with shell script: script/fix-slow-dns.sh virtualbox-iso: sudo: sudo を実行するには tty がなければいけません。すみません ==> virtualbox-iso: Unregistering and deleting virtual machine... ==> virtualbox-iso: Deleting output directory... Build 'virtualbox-iso' errored: Script exited with non-zero exit status: 1 ==> Some builds didn't complete successfully and had errors: --> virtualbox-iso: Script exited with non-zero exit status: 1 ==> Builds finished but no artifacts were created.

2015年7月31日 · 2 分

NginxTool

$ git clone git@gist.github.com:7752aaa4aac58aa400b9.git bin $ wget -qO- https://gist.github.com/hdknr/7752aaa4aac58aa400b9/archive/ac76968b64cbe682964880afc68b08bd54fc9987.zip | bsdtar -xvf-

2015年7月21日 · 1 分