Running parsoid server in the background for MediaWiki's visual editor

Questions and mods regarding system management may go here
Forum rules
We've moved! Head over to Synology Community (community.synology.com) to meet up with our team and other Synology enthusiasts!
keysuck
I'm New!
I'm New!
Posts: 8
Joined: Tue Mar 26, 2013 9:27 am

Running parsoid server in the background for MediaWiki's visual editor

Unread post by keysuck » Mon Feb 22, 2016 7:25 am

I've been struggling trying to run parsoid server in the backend in order to enable visual editor for MediaWiki.
So far, I've managed to run the server manually via putty but the terminal window must remain open in order to enable visual editing.
In other words, the parsoid server would not remain running in the background.
I am not a programmer so I have very limited knowledge in node.js and autostart.
Is there anyone who would like me to guide me through?

jamieknowles
I'm New!
I'm New!
Posts: 1
Joined: Wed Jun 22, 2016 1:34 am

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by jamieknowles » Wed Jun 22, 2016 1:36 am

Hey did you manage to get it working? I'm going through the same pain? I now have a new version of MediaWiki with VisualEditor but cant use it! :?

j.xavier.atero
Rookie
Rookie
Posts: 30
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by j.xavier.atero » Wed Aug 31, 2016 12:12 pm

Option 1: Task Scheduler (DSM 6.0)

Steps:
  • - Create the following script: /path_to_script/parsoid.sh (with chmod 755)

Code: Select all

cd /usr/local/packages/parsoid
node bin/server.js
where: /usr/local/packages/parsoid is the path to the parsoid installation
  • - Go to your Synology DiskStation: http://your-synology-server-here:5000
    - Control Panel > Task Scheduler
    - Create > Triggered Task > User-defined Script
    - Create Task
    • - General:
      • - Task: parsoid
        - User: root
        - Event: Boot-up
      - Task Settings:
      • - User-defined script: /path_to_script/parsoid.sh
    - Click OK and make sure the Enabled checkbox is ticked
The script can be tested by pressing the Run button

j.xavier.atero
Rookie
Rookie
Posts: 30
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by j.xavier.atero » Wed Aug 31, 2016 12:49 pm

Option 2: Upstart (DSM 6.0)

This option works when the service is started manually, but if fails to start automatically on boot. Well defined .conf files in /etc/init should be executed by Upstart but for some reason it does not work with DSM 6.0 on boot


Step 1: Create the config file /etc/init/parsoid.conf

Code: Select all

cd /etc/init
sudo vi parsoid.conf
With the content:

Code: Select all

# vim: set ft=upstart:

# Upstart job configuration for Parsoid

description "Parsoid HTTP service"

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

setuid "root"
setgid "root"

env VCAP_APP_PORT="8000"
env NODE_PATH="/usr/local/bin"

chdir "/usr/local/packages/parsoid"
exec node bin/server.js

respawn
where: /usr/local/packages/parsoid is the path to the parsoid installation

Step 2: Test the service manually

Code: Select all

sudo start parsoid
the following message should be displayed with the proper porcess number

Code: Select all

parsoid start/running, process 11692
to stop parsoid:

Code: Select all

sudo stop parsoid
Step 3: Try to autostart service

Code: Select all

shutdown -r now 
give some time for the service to become active.

The log contains an entry for the manual start, but not no information about being started on boot

Code: Select all

sudo more /var/log/upstart/parsoid.log
Any ideas?
Last edited by j.xavier.atero on Mon Nov 06, 2017 12:11 am, edited 1 time in total.

j.xavier.atero
Rookie
Rookie
Posts: 30
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by j.xavier.atero » Wed Aug 31, 2016 1:13 pm

Option 3: Script (DSM 6.0)

This option works when the service is started manually, but if fails to start automatically on boot. According to the 3rd-Party Package Developer Guide: https://global.download.synology.com/do ... _Guide.pdf
this is how to Run Scripts When the System Boots:
If you would like to run scripts when the system is booting up or shutting down, you can write scripts in start-stop-status. This script
will be executed with the "start" or "stop" parameter, when the package is enabled. If you want to execute a script during the boot-up or
shut-down process, you can put a start-up script in /usr/local/etc/rc.d/. Below are the rules for the start-up script:
1. It must contain the suffix ".sh". For example, "myprog.sh".
2. The permission must be 755.
3. It must contain the options of "start" and "stop". When the system boots up, it will call myprog.sh start ; when it shuts down, it
will call myprog.sh stop .


Step 1: Create the script file /usr/local/etc/rc.d/parsoid.sh

Code: Select all

cd /usr/local/etc/rc.d
sudo vi parsoid.sh
With the content:

Code: Select all

#!/bin/sh

start(){
    cd "/usr/local/packages/parsoid"
    node bin/server.js &
}

stop () {
    killall node
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  retart)
    stop
    start
    ;;
  *)
where: /usr/local/packages/parsoid is the path to the parsoid installation

Step 2: Test the service manually

Code: Select all

sudo sh ./parsoid.sh start
Step 3: Try to autostart service

Code: Select all

shutdown -r now 
give some time for the service to become active.

The log contains an entry for the manual start, but not no information about being started on boot

Code: Select all

sudo more /var/log/upstart/parsoid.log
Any ideas?
Last edited by j.xavier.atero on Mon Nov 06, 2017 12:13 am, edited 1 time in total.

sohansen
I'm New!
I'm New!
Posts: 1
Joined: Thu Oct 06, 2016 2:49 pm

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by sohansen » Thu Oct 06, 2016 2:58 pm

How did you install Parsoid on the Synology in the first place?
I doesn't come as a package... Do you apply any tweaks to Linux installation?

I have had partial success with the following steps:
- I have 'Node.js v4' and 'Node.js 0.10' installed through DSM package manager
- I followed instructions at https://www.mediawiki.org/wiki/Parsoid/Developer_Setup
- Following https://www.mediawiki.org/wiki/Topic:T5g50mmwvx76wszc I uncommented 'loadWMF: true' in config.yaml

when I run parsoid I am able to access and test at http://192.168.1.3:8000/

However, setting up config.yaml and LocalSettings.php the best I can, does not allow me to connect VisualEditor to Parsoid. - I get this error log in the running terminal:

TypeError: env.log is not a function
at Object.apiUtils.sendResponse (/volume1/homes/adminAHT/parsoid/lib/api/apiUtils.js:86:7)
at /volume1/homes/adminAHT/parsoid/lib/api/routes.js:155:15
at tryCatch2 (/volume1/homes/adminAHT/parsoid/node_modules/babybird/lib/promise.js:48:12)
at PrFunPromise.Promise (/volume1/homes/adminAHT/parsoid/node_modules/babybird/lib/promise.js:458:15)
at new PrFunPromise (/volume1/homes/adminAHT/parsoid/node_modules/prfun/lib/index.js:101:21)
at errBack (/volume1/homes/adminAHT/parsoid/lib/api/routes.js:148:12)
at /volume1/homes/adminAHT/parsoid/lib/api/routes.js:205:4
at tryCatch1 (/volume1/homes/adminAHT/parsoid/node_modules/babybird/lib/promise.js:40:12)
at promiseReactionJob (/volume1/homes/adminAHT/parsoid/node_modules/babybird/lib/promise.js:269:19)
at PromiseReactionJobTask.call (/volume1/homes/adminAHT/parsoid/node_modules/babybird/lib/promise.js:284:3)
at flush (/volume1/homes/adminAHT/parsoid/node_modules/babybird/node_modules/asap/raw.js:50:29)
at nextTickCallbackWith0Args (node.js:419:9)
at process._tickCallback (node.js:348:13)

Is anybody able to see where I am failing?

Edit:
I found out what the mistake was.
In config.yaml I had written a wrong path for api.php
- You can verify the path by pasting it in a browser which should then take you to a working page with API help text.
I needed to use:
uri: 'http://192.168.1.3/MediaWiki/api.php'

You can replace the IP-adress with 'localhost'

regards, Anders

j.xavier.atero
Rookie
Rookie
Posts: 30
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by j.xavier.atero » Fri Nov 03, 2017 1:06 pm

Quick steps to install parsoid (in DSM 6.1):

Step 1: Install Git, Node.js and curl
  • - Web Station > PHP Settings > Extensions
    • - enable curl
Step 2: Install Parsoid

From the console:

Code: Select all

cd /usr/local/packages
git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid
cd parsoid
sudo npm install
Step 3: Configure Parsoid

Create config.yaml file

Code: Select all

cp config.example.yaml config.yaml
Edit file and replace uri: 'http://localhost/w/api.php' by uri: 'http://localhost/path_to_your_wiki/api.php'.

Extended information in: https://www.mediawiki.org/wiki/Parsoid/Setup

Step 4: Start Parsoid

Check previous posts

Step 5: Test Parsoid
  • - From the browser check port 8000 of the server (http://your_server_ip:8000), the Welcome to the Parsoid web service. message should be displayed.
    - As an additional check, display the parsoid output for the Main Page. Open in the brwoser:
    • - http://your_wiki_url:8000/localhost/v3/page/html/Main_Page
      - http://your_wiki_url/api.php?action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en

edifyyo
I'm New!
I'm New!
Posts: 1
Joined: Thu May 09, 2013 3:56 pm

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by edifyyo » Thu Nov 09, 2017 4:28 pm

j.xavier.atero, thank you for DSM 6.1 updated instructions! How are you currently autostarting parsoid on 6.1?

j.xavier.atero
Rookie
Rookie
Posts: 30
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by j.xavier.atero » Tue Nov 14, 2017 1:34 am

I am autostarting parsoid using the Option 1: Task Scheduler described above in this post.

WilliamQin
I'm New!
I'm New!
Posts: 1
Joined: Tue Jan 09, 2018 3:26 pm

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by WilliamQin » Tue Jan 09, 2018 3:46 pm

Dear j.xavier.atero and everybody:

3 questions:

1./usr/local/packages/parsoid# sudo npm install
echo: npm WARN prefer global jshint@2.9.4 should be installed with -g
how deal with?

2.change LocalSettings.php, add : require_once("$IP/extensions/VisualEditor/VisualEditor.php");
the IE echo HTTP ERROR 500
what's the wrong?

3. is this must in LocalSettings.php: $wgVisualEditorParsoidURL = 'http://localhost:8000';

Thanks a lot^_^

j.xavier.atero
Rookie
Rookie
Posts: 30
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by j.xavier.atero » Sat Jan 20, 2018 10:07 pm

WilliamQin wrote:Dear j.xavier.atero and everybody:

3 questions:

1./usr/local/packages/parsoid# sudo npm install
echo: npm WARN prefer global jshint@2.9.4 should be installed with -g
how deal with?

2.change LocalSettings.php, add : require_once("$IP/extensions/VisualEditor/VisualEditor.php");
the IE echo HTTP ERROR 500
what's the wrong?

3. is this must in LocalSettings.php: $wgVisualEditorParsoidURL = 'http://localhost:8000';

Thanks a lot^_^
1. The warning is indicating that the package should preferably be installed globally. jshint package is in the "devDependencies" as you can see in /usr/local/packages/parsoid/package.json. You could ingnore this warning or install jshint package globally https://docs.npmjs.com/getting-started/ ... s-globally

2. Being a 500 error I will assume that it is not working in any browser. It might be due to an incorrect configuration of parsoid. You should check the logs to debug the error.

3. No, you can indicate the parsoid url using $wgVirtualRestConfig. You can check the VisualEditor set up here: https://www.mediawiki.org/wiki/Extension:VisualEditor. This is a sample of a working LocalSettings.php configuration:

Code: Select all


...

require_once "$IP/extensions/VisualEditor/VisualEditor.php";

$wgGroupPermissions['user']['collectionsaveasuserpage'] = true;

// Allow Visual Editor to read the pages
$local_ip = '127.0.0.1';
if ( $_SERVER['HTTP_X_REAL_IP'] == $local_ip ) {
	$wgGroupPermissions['*']['edit'] = true;
	$wgGroupPermissions['*']['read'] = true;
}else{
	$wgGroupPermissions['*']['edit'] = false;
	$wgGroupPermissions['*']['read'] = false;
}

// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;

// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';

$wgVirtualRestConfig['modules']['parsoid'] = array(
	// URL to the Parsoid instance
	// Use port 8142 if you use the Debian package
	'url' => 'http://localhost:8000',
	// Parsoid "domain", see below (optional)
	'domain' => 'localhost',
	// Parsoid "prefix", see below (optional)
	'prefix' => 'localhost'
);

// enable VisualEditor in namespaces
$wgVisualEditorAvailableNamespaces = array( 
	NS_TEMPLATE => true,
);

...


calego
Beginner
Beginner
Posts: 25
Joined: Sun Nov 22, 2015 3:30 pm

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by calego » Sun Feb 25, 2018 8:30 pm

When I try to run the command:

Code: Select all

git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/parsoid 
I get the following message:

Code: Select all

fatal: could not create work tree dir 'parsoid': Permission denied
It looks like some sort of permissions issue. I have made sure that I have read/write access on my admin account.
Any help appreciated, thanks!

calego
Beginner
Beginner
Posts: 25
Joined: Sun Nov 22, 2015 3:30 pm

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by calego » Tue Feb 27, 2018 9:42 pm

OK I got the Parsoid install command to run, but I get the following errors. I don't think it installed correctly.

Code: Select all

admin@DS418:/usr/local/packages/parsoid$ sudo npm install
npm WARN engine nsp@3.1.0: wanted: {"node":">=6.0.0"} (current: {"node":"4.8.4","npm":"2.15.11"})

> dtrace-provider@0.8.6 install /usr/local/packages/parsoid/node_modules/bunyan/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.8.4"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/packages/parsoid/node_modules/bunyan/node_modules/dtrace-provider/.node-gyp"
gyp ERR! build error
gyp ERR! stack Error: not found: make
     at getNotFoundError (/usr/local/lib/node_modules/npm/node_modules/which/which.js:14:12)
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:69:19)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:81:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:90:16
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Linux 4.4.15+
gyp ERR! command "/volume1/@appstore/Node.js_v4/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/packages/parsoid/node_modules/bunyan/node_modules/dtrace-provider
gyp ERR! node -v v4.8.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN prefer global jshint@2.9.4 should be installed with -g
simplediff@0.1.1 node_modules/simplediff

blafarm
Rookie
Rookie
Posts: 31
Joined: Mon Dec 06, 2010 11:57 pm

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by blafarm » Mon Mar 05, 2018 12:13 am

Apologies in advance for the Noob question, but this VisualEditor FAQ page states:

Can I install VisualEditor on my personal wiki outside Wikimedia?
Yes, at your own risk. VisualEditor and Parsoid extensions are available for download but they're still experimental; note that Parsoid requires nodeJS. If you do install and use them, please let us know what worked and what didn't in Phabricator.

Is there possibly a more simple way of implementing the VisualEditor?

Or, does adding this WYSIWYG functionality mean that you are going to need some advanced technical know how?

I'm not married to MediaWiki -- I'm just not interested in having to use Wikimarkup.

Thanks

j.xavier.atero
Rookie
Rookie
Posts: 30
Joined: Wed Aug 10, 2016 8:51 am
Location: Barcelona

Re: Running parsoid server in the background for MediaWiki's visual editor

Unread post by j.xavier.atero » Wed Mar 07, 2018 11:02 pm

blafarm wrote:Apologies in advance for the Noob question, but this VisualEditor FAQ page states:

Can I install VisualEditor on my personal wiki outside Wikimedia?
Yes, at your own risk. VisualEditor and Parsoid extensions are available for download but they're still experimental; note that Parsoid requires nodeJS. If you do install and use them, please let us know what worked and what didn't in Phabricator.

Is there possibly a more simple way of implementing the VisualEditor?

Or, does adding this WYSIWYG functionality mean that you are going to need some advanced technical know how?

I'm not married to MediaWiki -- I'm just not interested in having to use Wikimarkup.

Thanks
Getting VisualEditor to run takes some additional steps because it needs Parsoid to be installed and configured, but there should be enough documentation to guide you through the whole process. In my opinion, once installed it is quite user friendly.

Locked

Return to “System Managment Mods”