简体   繁体   English

pm2 deploy和gitlab私有存储库

[英]pm2 deploy and gitlab private repository

I want to deploy my app on my remote server using pm2 deploy . 我想使用pm2 deploy在我的远程服务器上部署我的应用程序。

Here is the content of my ecosystem.config.js file : 这是我的ecosystem.config.js文件的内容:

module.exports = {
  apps: [
    {
      name: `cms`,
      script: 'cms.js',
      env: {
        COMMON_VARIABLE: 'true'
      },
      env_development: {
        NODE_ENV: 'development',
      },
    }
  ],
  deploy: {
    development: {
      user: 'username',
      host: 'xxx.xxx.xxx.xxx',
      ref: 'origin/development',
      repo: 'git@gitlab.com:MyGitlabOrg/myproject.git',
      path: '/home/username/sites/development/cms',
      'post-deploy':
        '\
        mkdir -p logs && \
        npm install && \
        npm run install:development && npm run make:development && \
        NODE_ENV=development pm2 reload ecosystem.config.js --env development',
      ssh_options: ['StrictHostKeyChecking=no', 'PasswordAuthentication=no'],
      env: {
        NODE_ENV: 'development'
      }
    }
  }
};

And below is the command that I use in my term (on my local machine) : 以下是我在我的术语中使用的命令(在我的本地机器上):

$ pm2 deploy ecosystem.config.js development setup
--> Deploying to development environment
--> on host xxx.xxx.xxx.xxx
  â hook pre-setup
  â running setup
  â cloning git@gitlab.com:MyGitlabOrg/myproject.git
  â full fetch
Clonage dans '/home/username/sites/development/cms'...
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

  failed to clone

Deploy failed

As you can see I got this strange error GitLab: The project you were looking for could not be found. 正如你所看到的,我得到了这个奇怪的错误GitLab: The project you were looking for could not be found. ... ...

I've checked all ssh keys, I'm able to ssh to my remote server from my local machine and I'am also able to clone the repo from my remote server. 我检查了所有ssh密钥,我能够从我的本地机器ssh到我的远程服务器,我也能够从我的远程服务器克隆repo。

Do you have an idea how to fix this issue ? 你知道如何解决这个问题吗?

Thank you! 谢谢!

SSH into your server and run SSH进入您的服务器并运行

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

This will generate the private and public keys. 这将生成私钥和公钥。 Now copy the content of the public key to paste it on GitLab. 现在复制公钥的内容以将其粘贴到GitLab上。

cat /home/ubuntu/.ssh/id_rsa.pub

Next, check the SSH access to the repository 接下来,检查对存储库的SSH访问

ssh -T git@gitlab.com

You should see an welcome message from GitLab. 您应该看到来自GitLab的欢迎消息。

Now you are ready to deploy from PM2. 现在您已准备好从PM2部署。

根据上面的示例为非root用户设置ssh,因此必须为用户名设置ssh ...所以它将在/home/username/.ssh/id_rsa*中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM