Koozali.org formerly Contribs.org

NodeJS - running w/o SCL

Online Jáder

  • *
  • 1,046
    • LinuxFacil
NodeJS - running w/o SCL
« on: December 27, 2018, 01:49:57 AM »
I'm trying to put NodeJs to work without SCL.

I've been sucesfull using NodeJS v11.5.0 + PM2.. and I'll document it later (I'm taking notes!)

But right now I'm trying to get automatic support of app by create a new parameter on domains database to hold the NodeJS port number. So I did:
 
Code: [Select]
: db domains setprop w8k.jadermarasca.com.br NodePort 3001and created a new fragment template:
Code: [Select]
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/ProxyPassVirtualHosts/27ProxyNodeJSwith
Code: [Select]
{
    use esmith::DomainsDB;
    my $domains = esmith::DomainsDB->open_ro;

    my $nodeport = $domains->get_prop($virtualHost, "NodePort") || "disabled";

    $OUT = "";

    $OUT .= "    ProxyPass / http://localhost:$nodeport\n" unless $nodeport eq 'disabled';
    $OUT .= "    ProxyPassReverse / http://localhost:$nodeport\n" unless $nodeport eq 'disabled';
    $OUT .= "    #Jm END";
    return "    # Jm RETURN = skipping NodeJS NodePort \n" unless not $nodeport eq "disabled";
}

but even after a
Code: [Select]
expand-template /etc/httpd/conf/httpd.conf I cannot find the "Jm" marker . Note as AFAIK one of them should be added to httpd.conf even if it do not find any port on NodePort property.

So... please tell me what am I doing wrong... Thank you.
...

Offline mmccarn

  • *
  • 2,351
Re: NodeJS - running w/o SCL
« Reply #1 on: December 27, 2018, 12:30:12 PM »
The templates in ProxyPassVirtualHosts are activated by the domain property "ProxyPassTarget" and "TemplatePath":
https://wiki.contribs.org/SME_Server:Documentation:ProxyPass#ProxyPass_a_domain

To get your new template fragment included in httpd.conf you'd need to set "ProxyPassTarget" on the domain in question -- but then you could include the Node port and eliminate the custom template fragment:
Code: [Select]
db domains setprop w8k.jadermarasca.com.br ProxyPassTarget 'http://localhost:3001/'
db domains setprop w8k.jadermarasca.com.br TemplatePath ProxyPassVirtualHosts

Try moving your fragment into /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts instead.

Offline ReetP

  • *
  • 1,771
Re: NodeJS - running w/o SCL
« Reply #2 on: December 27, 2018, 04:45:03 PM »
You can use the NodeJS repo....

Check here:

https://wiki.contribs.org/User:ReetP

Just install the 'n' version manager to change version. Have a look at the rocketchat pages for some node & httpd/proxy stuff.

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Online Jáder

  • *
  • 1,046
    • LinuxFacil
Re: NodeJS - running w/o SCL
« Reply #3 on: December 28, 2018, 10:02:46 AM »
The templates in ProxyPassVirtualHosts are activated by the domain property "ProxyPassTarget" and "TemplatePath":
https://wiki.contribs.org/SME_Server:Documentation:ProxyPass#ProxyPass_a_domain

To get your new template fragment included in httpd.conf you'd need to set "ProxyPassTarget" on the domain in question -- but then you could include the Node port and eliminate the custom template fragment:
Code: [Select]
db domains setprop w8k.jadermarasca.com.br ProxyPassTarget 'http://localhost:3001/'
db domains setprop w8k.jadermarasca.com.br TemplatePath ProxyPassVirtualHosts

Try moving your fragment into /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts instead.

Thank you by your tip about to move fragment to VirtualHost. It's working now.
I'm just do not understand about to use ProxyPass: am I doing that on wrong way (or a mor difficult way) ??

...

Offline mmccarn

  • *
  • 2,351
Re: NodeJS - running w/o SCL
« Reply #4 on: December 28, 2018, 01:05:13 PM »
I'm just do not understand about to use ProxyPass: am I doing that on wrong way (or a mor difficult way) ??

That depends on your actual requirements and objectives.

If the existing proxypass functionality works for your use case, then yes - creating a new custom template (and presumably getting it accepted by the devs so you don't have to maintain it manually forever) is more difficult than using the existing system.

If there is some aspect of the current system that is not working for you then we'd have to know what that is and weigh the pros and cons of creating a new template fragment vs adjusting the existing fragment.

If you can get the result you need with no (or minor) modifications to the existing system, it might be less work to adjust the existing system rather than creating a new system -- but choosing incremental solutions time after time ultimately results in a more complex and convoluted system than if you stop and do some conscious system design now and then.

...and finally -- no system is done (in my opinion) until the wiki is updated - so you need to include in your easier/harder/right/wrong calculations the effort to find or create a home on the wiki for documenting the new system...