Showing posts from 2015

Running a meteor shell on a standalone server

For those that want to connect to meteor's shell running on a standalone/self-maintained server, the standard command you use in the development environment doesn't work. Fortunately you can 'trick' it into allowing the `meteor shell` command. APPDIR=/opt/bitnami/apps/myapp export METEOR_SHELL_DIR="$APPDIR/.meteor/local/shell" # other settings # ... exec node $APPDIR/bundle/main.js cd /opt/bitnami/apps/myapp mkdir -p .meteor/local/shell echo > .meteor/packages echo 'METEOR@1.2.1\n' > .meteor/release meteor shell

Javascript (ECMAScript 5.1) Refresher

I’ve been recently working heavily on JavaScript based applications in both Node.js and a Chrome extension. After working mostly on Java, I thought I’d share the syntax, conventions and the new features of ECMAScript 5.1 and parts of the still pending version, ES6/ECMAScript 2015, that I’ve come across. Comparisons Operators== equal to === equal value and equal type != not equal !== not equal value or not equal type I saw something else I thought was a fancy notation: if (!!something)
//which is not a special operator, it just converts it to boolean, i.e a double not.
(!!something) === (!(!something))
//this would only be useful if you want to set a boolean to something truthy, i.e.
var a = "somevalue";
var asBoolean = !!"somevalue";
Object InitializerSomething I had thought was not a fully adopted syntax, was being able to specify the getter / setter functions in the initializer. (MDN Object initializer) var o = {
func1: function (p1, p2) {},
get prop1() { ret…

Cygwin, access control, default groups and just getting it playing nice

correcting current and default permissions If you've been messing with your permissions on copying data across from another NTFS system, some of the owners/groups may be off and the even after correcting the owners and their permissions, any new files don't have the right defaults. This simple script replaces the ACL records for each file and directory, giving the default permissions specified.
find $1 -type f -exec setfacl -f facl {} \; find $1 -type d -exec setfacl -f dacl {} \; dacl - directory permissionsuser::rwx group::rwx other:r-x default:user::rwx default:group::rwx default:other:r-x facl - File Permissionsuser::rw- group::rw- other:r-- default:user::rw- default:group::rw- default:other:r-- Specifying the default groups for users The documentation for cygwin is in depth but doesn't simply answer the question: How do I set the default group for a user? (in the out of the box configuration).
The starting point is the mkpasswd utility. These are the following steps…

Getting PHP FastCgi Process Manager (FPM) and nginx working in cygwin

Despite the popularity of nginx and php, I was surprised that it wasn't easiy to find a working configuration for PHP-FPM (fast cgi) with a nginx server in front, running on cygwin.
Once I had the right fragments of settings, it was a case of systematically trying them all out.

/etc/php5/php-fpm.conf:[global] pid = /var/run/ ;note: i create a /var/log/php dir owned by the service user/group ;this allows the permissions to be inherited easily on the filesystem error_log = /var/log/php/fpm-global.log ; cygwin user default is 256 rlimit_files = 1024 ;pool configuration, having a pool config per site means you can easily have a separate log file [www] ;they have to be set but the cygwin version ignores them ;user=service-user ;group-service-group ; The address on which to accept FastCGI requests. listen = ; or ; listen = tmp/php-cgi.socket ; for socket unset these: listen.owner=service-user ; this allows the process pool to be q…

Remote debugging PHP from phpStorm

Despite all the documentation out there, it seemed to take me longer than it should. Although in hindsight, it could have been working originally as phpStorm's indicator that it's debugging is subtle.

Debug session within phpStorm Two articles to get you started:
phpStorm Help: Configuring XdebugphpStorm Confluence: Xdebug Installation Guide
To setup follow do the following:
For chrome (probably the easiest), install this plugin: Chrome PluginConfigure the plugin and select phpStorm as your IDE.Next sign onto your remote server and enable xdebug modulefor cPanel, click select php version (only 5.4 and 5.5 supported)update versioncheck the xdebug moduleclick updateEdit the php.ini, e.g. for cPanel, edit or create: /home/[username]/public_html/.user.ini
; Settings for xdebug module was already loaded on this machine: ; zend_extension=/opt/alt/php54/usr/lib64/php/modules/ xdebug.remote_host=[your modems IP address] xdebug.remote_port=[a port forwarded through your modem …

Good defaults for Wordpress (on a cPanel server)

After spending some time finding problems in a few Wordpress sites, both local in my dev environment and on a cPanel hosted server, I finally decided to sit down and work out the best base settings for each environment. The settings I've picked are mainly around dev and debugging, however I will try and keep this post updated as I come across new settings.

php.ini settings Local Dev These settings can be set in your local dev env php.ini (e.g. in c:\php-installdir\php.ini)
display_errors = On display_startup_errors = On log_errors = On error_log = C:/temp/php-errors.log error_reporting = -1 Production / hosted On cpanel servers, create a file in public_html: ".user.ini" (/home/[user]/public_html/.user.ini). Its without quotes but starting with a dot. Similar contents but limited by what you can set.
display_errors = Off error_log = /home/[user]/logs/php-errors.log error_reporting = -1 Depending on the server you may be able to alternatively use .htaccess (/home/[user]/p…

Plex Framework 2.5.0 Plugin Manifest

I’ve found that the documentation on the website doesn’t tie up with the API that is currently included with Plex. So here’s the bits of data I’ve gleaned.
The plugins & directory structure of Plex is based around OSX / iOS Bundle Structures. Each plugin has an Info.plist file which is based off Apple’s one (the documentation is here) with some extra properties. Some of these are documented on Plex's site but some were missing. This is a near complete list of them all and what I could work out their purpose to be.
Keys for Info.plist taken from core.pyCFBundleIdentifierPlugin namePlexPluginClassType of plugin, default ‘Content’ (but is ‘Channel’ under bundleservices).
Values from[‘Content’, ‘Agent’, ‘Channel’, ‘Resource’, ‘System’]PlexPluginTitleThe display namePlexPluginIconResourceNameDefault: 'icon-default.png'PlexPluginArtResourceNameDefault: 'art-default.jpg'PlexPluginTitleBarResourceNameDefault: 'titlebar-default.png'PlexPluginDevMo…

Repairing Windows Tools & Articles

For those times when we all think that it surely must be a simple thing to fix an annoying windows problem your facing than reinstalling or for those times when you forgot to take a recent full system image:Here is a compilation of tools and articles I’ve used to try and fix some windows registry / component problems.View ALL the hidden devices in device managerGhost/Hidden Network Interfaces
Repairing corrupt files using SFC (Windows 7/8)Use the System File Checker tool to repair missing or corrupted system files
Repairing corrupt files using SFC (Windows 8 / Server 2012)Fixing component store corruption in Windows 8 and Windows Server 2012
Resetting the TCP/IP stackHow to reset TCP/IP by using the NetShell utility
Windows 7: Wifi adapter could not bind IP protocol stack to network adapterChecking USB2/3 connection speedVerifying USB connection speed (USB 3 or USB 2?)Comparing registry changes REGDIFF – compares 2 exports, compares an export and current, sorts and merges.
I found that und…

Developing Plex Media Server Plugins

Plex Media Server has a nicely extensible API for writing plugins which are classified into channels, agents and services. However in trying to tweak a plugin I wanted to get working, I’ve discovered that the API that forms the latest Plex Media Server doesn’t match up with the API Reference provided. My next post I’ll give dumps of the runtime API and the differences in the object model – which aren’t too much of a big deal unless your doing audio only plugins (I’m getting a streaming radio station channel working). There also didn’t seem to be a SDK or toolset for developing the plugins, which upon looking at the plugin bootstrap procedure I can understand why – a lot of the classes are dynamically generated and together with some other imports, are set as global variables on the plugin’s executed I spent a bit of time trying to get PyDev to compile using some hackery but the way I was trying to do it I hit too many hurdles. I was trying to add the globals that are expo…

Diagnosing MQ client and resource adapter problems via trace logging

Standalone tracing WebSphere MQ classes for JMS applicationsIt’s a relatively simple process to enable logging for MQ JMS client libraries.
1. Add a reference WebSphere MQ classes for JMS configuration file.
Here is the command line arguments to reference the common services properties files called “” for MQ.
Note: the location for the MQ classes for JMS is a uri (i.e. prefix it with file:) whilst the location for MQ classes for Java is a regular path and annoyingly it won’t give you an error if it can’t correctly read the file.
Also included is a reference to a java keystore and turning on logging for SSL and connection handshaking as getting MQ and SSL working seems to be a constant battle, with cipher suites being the most common cause. I even had trouble trying to use the same ssl/cipher from WLP in both standalone JMS and in the non-JMS setup. It seems to require some trial and error for each of the 3 ways of using MQ listed here.…

Keeping a windows process after a jenkins job

One of our jobs on Jenkins is to deploy and startup an application server on a remote slave. However we were having 2 problems with it:
1. the job wasn’t finishing
2. when we terminated it from jenkins, it killed the process it had spawned (the application server).

I spent ages butting my head against Jython on windows, which in hindsight, I could have saved a lot of time if I'd seen how little of the functionality I need from python/windows was implemented in jython/windows.

(1) was solved by getting the start command to write stdout/stderr to a file (irrespective of whether anything was written).

(2) I tried many elaborate solutions, still thinking it was a jython or windows related problem. After seeing it mentioned in blog posts a few times I finally got what they were saying.
Jenkins has a section on their site: Spawning processes from build. Now the key thing here I missed was the BUILD_ID environment variable. So unset it and as long as you've spawned a new process it s…

Low nproc limit prevents sudo'ing to another user

A while ago I posted a solution to OutOfMemoryError: unable to create new native thread, however I encountered a problem caused by the nproc setting but wasn't fixable by a simple ulimit command. The problem we were encountering was that we couldn't sudo into service account when we had all our application servers running.

Our sysadmins have setup a user escalation script, which there's nothing wrong with. It does some prechecks, sudos a script under the requested user, does some logging, then does an exec <configured shell> . When there are too many processes, it manages to run the 2nd script as the user, however the exec command blocks, it never gets to the profile script to execute the ulimit command.
I traced it down to the default soft limit for the number of process for all users to 1024.
Our process count is way above that, which means when it tries to create a new process for bash when we run the sudo script, it can’t. So we are unable to sign into the accou…