简体   繁体   中英

Starting PhantomJS server 'automatically' with Hound / Phoenix

I'm wanting to leverage some of the functionality of PhantomJS through Hound for users visiting my site. Since the 'PhantomJS webdriver server' has to be started first, I'm trying to figure out a way that this can happen 'automatically' (ie, either when a user first visits the site, or when they visit the page that uses Hound). I figure it'd be best if this could be handled by Phoenix somehow, since Phoenix is already handling all the users requests, rather than an additional technology juggling everything. Maybe something with npm or brunch or something. I'd greatly appreciate any specific or general advice on this. Thanks!

Well I figured a thing that will probably work. Inside my view or controller pertaining to where I want the functionality, it looks like I can do:

"phantomjs" |> String.to_char_list |> :os.cmd

[I tried the Elixir System.cmd("dir", []) as a test but it didn't seem to like the fact I was using Windows or something (?) and kept giving an :enoent error.]

Originally I was going to use Hound but now I'll probably just use PhantomJS, since all I really want is screenshots and automation, not necessarily testing, so that will ultimately be "phantomjs myscript.js ".

According to documentation on System.cmd , "this function uses a Port for interacting with the outside world". Not sure how that compares with os:cmd .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM