Chinaunix首页 | 论坛 | 博客
  • 博客访问: 746218
  • 博文数量: 176
  • 博客积分: 2548
  • 博客等级: 少校
  • 技术积分: 1749
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-29 16:36
个人简介

爱咋咋地

文章分类

全部博文(176)

文章存档

2024年(1)

2023年(17)

2022年(19)

2021年(3)

2020年(1)

2018年(1)

2017年(1)

2014年(1)

2013年(4)

2012年(11)

2011年(19)

2010年(22)

2009年(71)

2008年(5)

分类: LINUX

2022-04-24 16:53:34

今天琢磨琢磨nightmareJS, 在测试机器上跑的好好的,往服务器一放就完蛋了,服务器上没有X环境。上网找了一下,遇到一位国外大哥的文章,亲测有效。

RUNNING NIGHTMAREJS ON CENTOS 6
APRIL 26, 2017 RICH
Most posts on this site aren’t exactly riveting to read, but they might just save you hours and hours of work.  This one is no different!


NightmareJS is fantastic, but due to its reliance on Electron and a strange mix of dependencies, getting it to work on CentOS is very involved.  Lucky for you, I’ve compiled all of the necessary commands and even compiled binaries/libraries to save you from losing what’s left of your hair.


These instructions have been tested on CentOS 6.7.


Install Prerequisites
X-related Packages
Xvfb is required to provide the pseudo-headless-X environment; libXScrnSaver is required to add libXss.so.1.


[root@backend ~]$ yum install xorg-x11-server-Xvfb libXScrnSaver
MS fonts
(More info: )


[root@backend ~]# yum install curl cabextract xorg-x11-font-utils fontconfig
 [root@backend ~]# rpm -i
Upgrade gcc library
I’ve already done the hard work for you and compiled gcc 6.3 from source on CentOS 6.8, 64 bit.  Download the library at %2B%2B.so.6.0.22-CentOS-6.tar.gz.  Extract it to the home directory of whichever user you’re logged in as (in my case, root).  Then, install it using the following instructions:


[root@backend ~]# cd /usr/lib64/
 [root@backend lib64]# mv ~/libstdc++.so.6.0.22 .
 [root@backend lib64]# ls -alF libstdc++.so.6*
 lrwxrwxrwx 1 root root 19 Oct 1 2015 libstdc++.so.6 -> libstdc++.so.6.0.13*
 -rwxr-xr-x 1 root root 987096 Jul 22 2015 libstdc++.so.6.0.13*
 -rwxr-xr-x 1 root root 11508835 Apr 25 18:53 libstdc++.so.6.0.22*
 #Notice the symbolic link to 6.0.13
 [root@backend lib64]# rm libstdc++.so.6
 [root@backend lib64]# ln -s libstdc++.so.6.0.22 libstdc++.so.6
 [root@backend lib64]# ls -alF /usr/lib64/libstdc++.so.6*
 lrwxrwxrwx 1 root root 19 Apr 26 18:34 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.22*
 -rwxr-xr-x 1 root root 987096 Jul 22 2015 /usr/lib64/libstdc++.so.6.0.13*
 -rwxr-xr-x 1 root root 11508835 Apr 25 18:53 /usr/lib64/libstdc++.so.6.0.22*
 #Notice the symbolic link to 6.0.22
 [root@backend lib64]# cd
 [root@backend ~]# strings /usr/lib64/libstdc++.so.6 | grep GLIB
Before, we only had strings up until GLIBCXX_3.4.13, but now we have strings up until GLIBCXX_3.4.22. (Our version of Electron requires GLIBCXX_3.4.15)


Update glib library
Follow the nice instructions of some friendly gents over on GitHub to install an updated version of glib that will support Electron (NightmareJS).  More info:


[root@backend ~]# cd /opt
 [root@backend opt]# wget
 [root@backend opt]# tar xzf gcc-4.7.2.tar.gz
 [root@backend opt]# rm gcc-4.7.2.tar.gz
 [root@backend opt]# cd /etc/ld.so.conf.d/
 [root@backend ld.so.conf.d]# nano gcc-4.7.2.conf
Into this file, paste the following:


/opt/gcc-4.7.2/glib-2.49.4-kgesagxmtbemim2denf65on4iixy3miy/lib
 /opt/gcc-4.7.2/libffi-3.2.1-wk2luzhfdpbievnqqtu24pi774esyqye/lib64
 /opt/gcc-4.7.2/pcre-8.39-itdbuzevbtzqeqrvna47wstwczud67wx/lib
 /opt/gcc-4.7.2/gettext-0.19.8.1-aoweyaoufujdlobl7dphb2gdrhuhikil/lib
[root@backend ld.so.conf.d]# ldconfig
 [root@backend ld.so.conf.d]# ldconfig -p | grep "libglib"
Check for glib-2.49.4.


Set up D-Bus library
This step might not be necessary.  On the first machine I performed these steps, I didn’t need to do this, but on the second one, I did.  When running your NightmareJS script, if you get an error about the D-Bus library not being set up correctly, execute this simple command (Thanks to Tork Wrench).


[root@backend ~]# dbus-uuidgen > /var/lib/dbus/machine-id
Finally – Running NightmareJS!
[dev@backend ~]$ cd project/
 [dev@backend your-project]$ rm -rf node_modules/
 [dev@backend your-project]$ npm install
 [dev@backend your-project]$ DEBUG=nightmare*,electron* xvfb-run -a --server-args="-screen 0 1280x2000x24" node your-script.js -- --progress=false --single-run --watch=false
Note – this is likely not the best command for you; in fact it almost certainly is not. Experimentation will be needed in adding/removing/changing flags.  However, this should hopefully be enough to verify that NightmareJS is in a functional state.


*I made it all the way through this post without making an obvious pun about how hard it is to get NightmareJS running on CentOS.  I hope I’ve made you proud!



讨ht的tps://endorkins.com/2017/04/26/running-nightmarejs-on-centos-6/
阅读(365) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~