Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic NodeJS support #3277

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open

Conversation

darkworks
Copy link
Contributor

basic node js support taken from : https://github.com/cristiancosano/hestiacp-nodejs

thanks

added npm and pm2 packages
added npm and pm2 packages
node js templates
node js templates
security patch
security patch
added nvm installation
added nvm installation
@jaapmarcus jaapmarcus self-requested a review February 20, 2023 12:08
@jaapmarcus
Copy link
Member

Need some minor changes so Nginx only servers can enjoy this feature aswell.

Also need to test it :)

Copy link
Member

@jaapmarcus jaapmarcus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need the templates in nginx/php-fpm folder

For nginx only setups

@darkworks
Copy link
Contributor Author

darkworks commented Feb 20, 2023

  • also it will be good if we can add PM2 support to hestia so that it can keep eye on node apps and can stop restart apps directly from hestia panel inside.

something like this : https://github.com/Steveorevo/hestiacp-nodeapp

@darkworks
Copy link
Contributor Author

this might be helpful : https://github.com/Steveorevo/hestiacp-nodeapp

@Steveorevo
Copy link
Contributor

My project is reaching maturity. While no CLI access is needed, the user account does need to be set to allow bash login. Without having to actually access the user account, most everything can be done via the control panel; prototype does the following:

  • Utilizes a basic PM2 template that resolves port, NodeJS application to start
  • With the presence of a PM2 template, a unique port is reserved for nginx reverse proxy and saved in hestia/data
  • Starts/stops the NodeJS app on: Proxy Template change, web domain suspend, and web domain resume
  • Cleans up port allocation on domain delete or when app files are deleted (pause/resume web domain to check)
  • Reverse proxy includes web sockets upgrade support by default
  • Reverse proxy automatically accounts for root domain or subfolder (simply move files to a subfolder within nodeapp folder that is adjacent to public_html and pause/resume services).
  • The API allows for unique ports to be reserved per web domain, per user account, or system wide

Unfortunately this does require a few core patches to work (see https://github.com/steveorevo/hestiacp-pluginable). I created pluginable to allow me to quickly prototype ideas on Hestia. It is not for runtime, and probably won't survive core upgrades (i.e. Hestia 1.7). Would be nice if HestiaCP adopts an event driven API like what pluginable modifies core to do; but until then; NodeJS support would require extensive core modifications.

install/deb/templates/web/nginx/php-fpm/NodeJS.tpl Outdated Show resolved Hide resolved
install/deb/templates/web/nginx/php-fpm/NodeJS.stpl Outdated Show resolved Hide resolved
install/deb/templates/web/nginx/NodeJS.stpl Outdated Show resolved Hide resolved
install/rpm/templates/web/nginx/NodeJS.stpl Outdated Show resolved Hide resolved
install/rpm/templates/web/nginx/php-fpm/NodeJS.stpl Outdated Show resolved Hide resolved
install/rpm/templates/web/nginx/php-fpm/NodeJS.stpl Outdated Show resolved Hide resolved
install/rpm/templates/web/nginx/php-fpm/NodeJS.tpl Outdated Show resolved Hide resolved
@darkworks
Copy link
Contributor Author

https://drone.hestiacp.com/hestiacp/hestiacp/1484/2/7

There are some issues in the templates

Probally for nginx + php-fpm you haven't replace proxy_port and proxy_ssl_port with web_port and web_ssl_port

The last tests fail due to bug with Lets encrypt need to spend some time on it ...

ok thanks for the correction i replaced

proxy_port and proxy_ssl_port with web_port and web_ssl_port

@amiruldev20
Copy link

its work running nodejs & php ?

@darkworks
Copy link
Contributor Author

its work running nodejs & php ?

ya

@darkworks
Copy link
Contributor Author

@jaapmarcus can you please review it , that why build is failing

thanks

@jaapmarcus
Copy link
Member

@jaapmarcus can you please review it , that why build is failing

thanks

Never commit changes with out a merge / rebase from an upstream branch.

We have made some major changes to building javascript in the last few weeks causing things to break in this PR...

@Fameing
Copy link

Fameing commented Aug 11, 2023

Hi All, will there be any further progress on this?

@Steveorevo
Copy link
Contributor

@Steveorevo pls contribute to this nodeJS feature of hestiacp. i copied your work as basic nodejs support however we need your help with more advance support like integration of pm2 etc with hestia panel .
thanks

Would HestiaCP please consider merging my "pluginable" project? This is the base for how I incorporate NodeJS and extensive functionality to HestiaCP.

@jaapmarcus
Copy link
Member

Implementation in this PR sucks a lot it will not work in specific method and so on..

@Steveorevo I fin e with it how ever current ipv6 support and changes to the admin user have a higher priority for me. And it will cause many merge conflicts...

@Steveorevo
Copy link
Contributor

Steveorevo commented Aug 12, 2023

I could submit a PR that adds web/pluginable.php but there are a half dozen lines that also need to be changed in main.php as well as two other files for hooks. That might be a point of contention as it intercepts ALL bin calls with a PHP script. To date; HestiaCP is very (and nicely so) bash shell script centric. Not sure how everyone will feel about a PHP injection or its event driven programming model for plugins.

@Jamiul-Bari
Copy link

Please kindly consider this feature. This will make this panel more complete as I do not have to manually configure NodeJS or look for other services to host react.js, next.js, etc for PHP-powered APIs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants