Create many vagrant servers in a time

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Create many vagrant servers in a time相关的知识,希望对你有一定的参考价值。


#https://github.com/r-trigo/postgres-repmgr-vagrant
Vagrant.configure("2") do |config|
  (1..2).each do |n|
    config.vm.define "node#n" do |define|
      define.ssh.insert_key = false
      define.vm.box = "generic/centos7"
      define.vm.hostname = "node#n"
     # define.vm.network :private_network, ip: "192.168.56.1#n"
      define.vm.network :public_network, ip: "192.168.56.1#n"
      # if you would like to use port forwarding, uncomment the line below
      define.vm.network :forwarded_port, guest: 5432, host: "543#n"
      
      define.vm.provider :virtualbox do |v|
        v.cpus = 1
        v.memory = 2048
        v.name = "node#n"
      end

      #config.vm.synced_folder "./", "/vagrant_data"


   
    end
    config.vm.provision "shell", inline: <<-SHELL

    echo -e "Stage 1"

    echo redhat | passwd root --stdin ;
    
    echo -e "192.168.56.11  node1 " >>/etc/hosts
    echo -e "192.168.56.12  node2 " >>/etc/hosts
    sed -i \'s/vault.centos.org/mirrors.aliyun.com/g\' /etc/yum.repos.d/CentOS*
   
    echo -e "Stage 2"
    sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    sudo yum -y install epel-release yum-utils
    # Install PostgreSQL:
    sudo yum-config-manager --enable pgdg14
    sudo yum install postgresql14-server postgresql14 -y



    # Optionally initialize the database and enable automatic start:
    sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
    sudo systemctl enable postgresql-14
    sudo systemctl start postgresql-14


    echo -e "Stage 3"
    sudo yum -y  install repmgr_14*

    echo -e " export PATH=/usr/pgsql-14/bin/:$PATH" >>/var/lib/pgsql/.bash_profile




    SHELL
  end
end


Nx CLI run many command 不适用于多个应用程序

【中文标题】Nx CLI run many command 不适用于多个应用程序【英文标题】:Nx CLI run many command is not working for multiple apps 【发布时间】:2021-07-23 16:13:32 【问题描述】:

我曾尝试使用 Nx 来尝试使用 Monorepos。我一直面临通过nx run-many 命令为多个应用程序提供服务的问题。如果我做错了什么,谁能纠正我?

使用的命令:nx run-many --target=serve --all

我可以看到 Nx 控制台记录了所有可用的应用程序,但只运行了一个

>  NX  Running target serve for projects:
  - app1
  - app2
———————————————————————————————————————————————
> nx run app1:serve 

【问题讨论】:

【参考方案1】:

试试这个:

nx run-many --parallel --target=serve --projects=frontend,backend 

【讨论】:

当我有多个nest.js 应用程序时,该命令应该可以工作,但是端口冲突。【参考方案2】:

您可以通过编辑package.json更改服务端口

"serve": 
      "executor": "@nrwl/web:dev-server",
      "options": 
        "buildTarget": "admin-web:build",
        "port": 4220,
        "hmr": true
      ,
      "configurations": 
        "production": 
          "buildTarget": "admin-web:build:production",
          "hmr": false
        
      
    

之后你可以运行nx run-many

nx run-many --parallel --target=serve --projects=frontend,backend 

【讨论】:

【参考方案3】:

这是由于端口覆盖造成的,例如,如果您有多个前端应用程序,它们将在同一个端口上运行。 您可以在 project.json 文件中管理每个项目的配置,并且可以为每个项目处理不同的端口。

示例:

"serve": 
  "executor": "@nrwl/web:dev-server",
  "options": 
    "buildTarget": "react-todo:build",
    "hmr": true,
    "port": 3001
  ,
  "configurations": 
    "production": 
      "buildTarget": "react-todo:build:production",
      "hmr": false
    
  
,

这是 (apps//project.json) 中的反应配置

【讨论】:

以上是关于Create many vagrant servers in a time的主要内容,如果未能解决你的问题,请参考以下文章

Why gdb crash if create too many threads ?

Jmeter连接Mysql出现Cannot create PoolableConnectionFactory (Could not create connection to database serv

001_vagrant利器

CREATE OR REPLACE TEMP TABLE in a script error: “Exceeded rate limits: too many table update operati

Nx CLI run many command 不适用于多个应用程序

odoo之可选择多个内容显示问题