📜 ⬆️ ⬇️

ServerSideJS: now easier than ever. Meet v8cgi!

v8cgi - a wrapper for the v8 JS engine from google. I was asked to put it on the server and he pleasantly surprised me with the unpredictable low gluttony and ease of use.

So, tasks:
1. Collect v8
2. Build v8cgi including as an Apache module
3. Configure the Apache.
4. Drink tea with caramel on this occasion.

v8


Prerequisite: python, subversion and scons (gcc is everywhere).
For the inexperienced: svn, scons, python-minimal packages will work in debian

Taking the source code from SVN
svn checkout v8.googlecode.com/svn/trunk v8-read-only
and, going to the resulting folder, run the constructor.
scons library=shared
Copy the newly collected file (libv8 * .so) to /usr/lib/libv8.so
')

cgi


Necessary: ​​apache, mysql and GD libraries
(deb packages: libmysqlclient15-dev libgd2-dev apache2-threaded-dev)
Optional: sqlite and fastcgi (libfcgi-dev libsqlite3-dev)
Be sure to fix about the 58th line of the Sconfigure file ../v8 to ../V8, otherwise the constructor will be dissatisfied.
We collect:
scons module=1 sqlite=0 fcgi=0

Collected. We have 2 files: mod_v8cgi.so and v8cgi, copy them to / home / v8, and the contents of the lib directory in / usr / lib / v8cgi.
The libv8cgi.conf.posix config is copied to /etc/v8cgi.conf

Apache


add 3 lines with cofig and the module is working.
LoadModule v8cgi_module /home/v8/mod_v8cgi.so
v8cgi_Config /etc/v8cgi.conf
AddHandler v8cgi-script .ssjs


Regarding the launch as a cgi program.
ScriptAlias /ssjs/ /home/lazutov/ssjs/
AddHandler v8cgi-handler .ssjs
Action v8cgi-handler /ssjs/v8cgi

In the errlolog, v8cgi swears for invalid headers and, as expected, drops 500 errors. Hands, what can you do :)

Conclusion


v8cgi earned with an unpredictable low memory consumption - 20-30 mb, against the expected 70-100.
JS received one more kick in the development of a completely different quality. Prospects? Horizons? Time will tell.
Tea
.
Oh. no caramels. No tea.
There is a very sour cherry. Fill it with boiling water and send some vitamins into the body :) By the way, not bad, I recommend.

Source: https://habr.com/ru/post/66455/


All Articles