PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
I have a repository set up in cPanel's Git Version Control with Pull deployment. Now, due to the project guidelines having changed, I would need to change this to push deployment.

I tried simply adding a cpanel.yml file to my repository as well as creating a brand new one (following the documentation at Guide to Git - How to Set Up Deployment - cPanel Knowledge Base - cPanel Documentation).

In both cases, when I try to git push -u origin HEAD from my local project, I get the following:


ssh: connect to host [domain].com port 22: Connection timed out
fatal: Could not read from remote repository.

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

How can I fix this?

EDIT

Would I need to somehow login to the ssh in my push command? Perhaps with --push-option or --exec?
 
Last edited:

PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
Hi HB,

Thanks for the reponse. Actually, in the time it took to get a response, I managed to debug the problem myself.

I am however still experiencing problems with the .cpanel.yml file, the documentation about this being quite sparse. I have it set up correctly to copy the repository content into 2 subfolders. I next need it to run some npm commands to auto-deploy my app. Here is the file:
Code:
---
deployment:
  tasks:
    - export DEPLOYPATHFRONT=/home/[user]/public_html/new_site/frontend
    - /bin/cp -R frontend/* $DEPLOYPATHFRONT
    - export DEPLOYPATHBACK=/home/[user]/public_html/new_site/backend
    - /bin/cp -R backend/* $DEPLOYPATHBACK
    - npm run build --prefix /home/[user]/public_html/new_site/backend
    - npm run start --prefix /home/[user]/public_html/new_site/backend
    - npm run build --prefix /home/[user]/public_html/new_site/frontend
    - npm run start --prefix /home/[user]/public_html/new_site/frontend
The first 4 lines of this are working fine. The lines relating to npm, which do work in a shell through ssh, don't seem to be running at all (I can't either seem to find errors being logged anywhere).

Would you have some insight into this?

Thanks!
 

cPanelHB

Technical Analyst
Staff member
Sep 6, 2018
42
7
83
Houston
cPanel Access Level
Root Administrator
Hello,

My suspicion is that the "npm" binary is likely not found in the $PATH environment variable of the running deployment script.

I assume you are using the ea-nodejs10 packages -- if so, can you add export PATH=/opt/cpanel/ea-nodejs10/bin/:$PATH near the start of your tasks to see if that resolves the issue? It would need to go above the npm lines.

We look forward to hearing back from you.
 
  • Like
Reactions: cPanelMichael

PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
Hi HB,

Thank you for the response. I'm not quite sure how to apply this to my code though.

I've updated the file to look like this:


Code:
---
deployment:
  tasks:
    - export DEPLOYPATHFRONT=/home/[user]/public_html/new_site/frontend
    - /bin/cp -R frontend/* $DEPLOYPATHFRONT
    - export DEPLOYPATHBACK=/home/[user]/public_html/new_site/backend
    - /bin/cp -R backend/* $DEPLOYPATHBACK
    - export PATH=/home/[user]/bin/:$PATH
    - npm run build --prefix /home/[user]/public_html/new_site/backend
    - npm run start --prefix /home/[user]/public_html/new_site/backend
I'm not using ea-nodejs10, I've installed it manually on the server in the bin directory. Do my 'npm run...' lines need to reference $PATH at all? And why does the PATH variable need to reference itself?

Thanks!
 

cPanelHB

Technical Analyst
Staff member
Sep 6, 2018
42
7
83
Houston
cPanel Access Level
Root Administrator
I'm not using ea-nodejs10, I've installed it manually on the server in the bin directory.
If you installed it system-wide to a normal bin directory (/usr/local/sbin, /usr/local/bin, /usr/sbin, or /usr/bin), then you likely don't need to worry about it. But I'll answer your other two questions.

Do my 'npm run...' lines need to reference $PATH at all?
No.

And why does the PATH variable need to reference itself?
It's to add to the existing variable without wiping out the current contents.

But in any case, lets take a step back. It will be a lot easier if you confirm what errors you are getting.

The lines relating to npm, which do work in a shell through ssh, don't seem to be running at all (I can't either seem to find errors being logged anywhere).
Any errors will be logged to /home/${USERNAME}/.cpanel/logs/vc_${EPOCH_TIMESTAMP}.${PID}_git_deploy.log

You should get the log location when you push your commit.

For example:

Code:
user:~/gittest/project $ git push [email protected]${IP}:./project
Enter passphrase for key '/Users/user/.ssh/id_rsa':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 268 bytes | 268.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Recieved update on checked-out branch, queueing deployment.
remote: ---
remote: apiversion: 3
remote: func: create
remote: module: VersionControlDeployment
remote: result:
remote: data:
remote:  deploy_id: 2
remote:  log_path: /home/gittest/.cpanel/logs/vc_1577411725.94144_git_deploy.log
remote:  repository_root: /home/gittest/project
remote:  sse_url: /sse/UserTasks/00000000_5e05648de646f9/vc_1577411725.94144_git_deploy.log
remote:  task_id: 00000000/5e05648de646f9
remote:  timestamps:
remote:   queued: '1577411726.01702'
remote: errors: ~
remote: messages: ~
remote: metadata: {}
remote:
remote: status: 1
remote: warnings: ~
To ${IP}:./project
  49d6da4..164896f master -> master
On your server, is there anything in /home/USERNAME/.cpanel/logs/ that provides information on what the problem is?
 
Last edited:

PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
Hi HB,

Sorry for the delay, the holidays quickly became a busy time for me.

I've located what seems to be the latest log file on this process, here is what it contains:


Code:
1576778783.182291412
$ export DEPLOYPATHFRONT=/home/[user]/public_html/new_site/frontend

Task completed with exit code 0.

1576778783.188624087
$ /bin/cp -R frontend/* $DEPLOYPATHFRONT
/bin/cp: 'frontend/components' and '/home/[user]/public_html/new_site/frontend/components' are the same file
/bin/cp: 'frontend/next.config.js' and '/home/[user]/public_html/new_site/frontend/next.config.js' are the same file
/bin/cp: 'frontend/node_modules' and '/home/[user]/public_html/new_site/frontend/node_modules' are the same file
/bin/cp: 'frontend/out' and '/home/[user]/public_html/new_site/frontend/out' are the same file
/bin/cp: 'frontend/package-lock.json' and '/home/[user]/public_html/new_site/frontend/package-lock.json' are the same file
/bin/cp: 'frontend/package.json' and '/home/[user]/public_html/new_site/frontend/package.json' are the same file
/bin/cp: 'frontend/pages' and '/home/[user]/public_html/new_site/frontend/pages' are the same file
/bin/cp: 'frontend/postcss.config.js' and '/home/[user]/public_html/new_site/frontend/postcss.config.js' are the same file
/bin/cp: 'frontend/static' and '/home/[user]/public_html/new_site/frontend/static' are the same file

Task completed with exit code 1.

1576778783.2155
Build completed with exit code 1
There doesn't seem to be any mention of npm or even of my backend folder.

Any idea where I can go from here?

EDIT

Thought it might also be useful to mention, there was no log path mentioned when I did my push. I found the log based on the file path you specified.
 
Last edited:

cPanelHB

Technical Analyst
Staff member
Sep 6, 2018
42
7
83
Houston
cPanel Access Level
Root Administrator
Hello,

The cp command is failing with an error that is preventing the other commands from running.

Based on the error, your git repo is directly in /home/user/public_html/new_site/ -- the cp command is failing because you're trying to copy files onto themselves.

If you're deploying directly to that directory, you don't need to copy the files as well.

What happens if you get rid of the first 4 or 5 tasks, leaving you with just the npm commands?
 

PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
Hi HB,

I've modified the .cpanel.yml file, leaving only the following:

Code:
---
deployment:
  tasks:
    - npm run build --prefix /home/vksappc/public_html/new_site/backend
    - npm run start --prefix /home/vksappc/public_html/new_site/backend
This does not seem to be working either. However, there is no longer a log created when I push my code to cPanel.

The only logging information I have is what is written to the terminal when I run git push:

Code:
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 366 bytes | 366.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Recieved update on checked-out branch, queueing deployment.
remote: ---
remote: apiversion: 3
remote: func: create
remote: module: VersionControlDeployment
remote: result:
remote:   data: ~
remote:   errors: ~
remote:   messages: ~
remote:   metadata: {}
remote:
remote:   status: 1
remote:   warnings: ~
To ssh://[ip]:[port]/home/[user]/public_html/new_site
   e7e35bac..cca785dc  HEAD -> master
Branch 'master' set up to track remote branch 'master' from 'cpanel'.
 

PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
Hi HB,

I believe that would be a yes to both questions. In the Git Version Control interface, I have a repository pointing to /home/[user]/public_html/new_site
And the .cpanel.yml file is in that directory, along with the folders /backend and /frontend, each containing their respective code and being the folders inside which I would like to run "npm start", using the --prefix command.
 

PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
Hi HB,

Sure. However, in order to do that, I will have to wait for my system administrator to be back from vacation next week as I do not have access to the proper account needed to submit the support ticket.

Thanks
 

PluggedP93

Member
Dec 4, 2019
20
3
3
Canada
cPanel Access Level
Website Owner
Hi HB,

Small update actually. Playing around with it and reinserting the "Export PATH" line, I managed to get it to work! Partially...

Here is what I have:

Code:
---
deployment:
  tasks:
    - export PATH=/home/vksappc/bin/:$PATH
    - npm run build --prefix /home/vksappc/public_html/new_site/backend
    - npm run start --prefix /home/vksappc/public_html/new_site/backend
    - npm run build --prefix /home/vksappc/public_html/new_site/frontend
    - npm run start --prefix /home/vksappc/public_html/new_site/frontend

And this really does work, the first time. If I run it again however, it breaks at " - npm run start --prefix /home/vksappc/public_html/new_site/backend" because the port is already in use, because the app is running. So I would need to somehow kill the app on that port before building and running it again, otherwise the new build on the backend will never go live and the frontend script won't happen at all. Any tips?

Thanks again!