Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use pm2 with CircleCI

I am using pm2 on my remote ubuntu server and CircleCI for CI, I've got the following configuration files:

version: 2.1
orbs:
  node: circleci/[email protected]
jobs:
  deploy-prod:
    docker:
    # specify the version you desire here (you might not want node)
    - image: circleci/node:7.10
    steps:
        - checkout
        - run: ssh -oStrictHostKeyChecking=no -v $DROPLET_USER@$DROPLET_IP ./deploy_project.sh $MICROSERVICE_NAME
workflows:
    build-and-test:
      jobs:
        - deploy-prod:
            filters:
              branches:
                only:
                  - master

In my deploy script I do the following:

cd /var/www/nodejs/$1
git pull [email protected]:DevandScorp/hippocrates_authorizationmicroservice.git
cd ..
pm2 restart ecosystem.config.js --only $1

But I've got the following error:

./deploy_project.sh: line 4: pm2: command not found

Is it possible to run my server's pm2 in CircleCI config or can I reload my microservice automatically in another way?

like image 782
Артем Дачевский Avatar asked Mar 11 '26 20:03

Артем Дачевский


1 Answers

So, if you want to make anything on your server using CircleCI, it's just a waste of time. CircleCI provides a virtual environment, where you can, for example, make some tests. Also you can push changes on your remote server, but CircleCI will not have any access to your server's system. So if we speak about pm2, you can enable watch mode and relaunch your microservice everytime CircleCI push changes to it

like image 78
Артем Дачевский Avatar answered Mar 14 '26 11:03

Артем Дачевский



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!