• Call: +1 (858) 429-9131

Tweaking APCu size for Phabricator

APCu is the substitute for the old APC extension. In APC extension it supports both opcode caching and data caching whereas APCu extension supports only data caching. Opcode caching is transparent at a source code level where as data caching is not.The main thing to note is that we need to allocate memory for APCu to use.

Configuration On Ubuntu System

First, we need to install the php7.1 module APCu.  We do with Usual ubuntu command Like this.

apt-get install php7.1-apcu

 

After the successful installation of the module, we need to modify the configuration file which is in most case at location

“/etc/php/7.1/mods-available/apcu.ini”

Then we need to Make changes in this file to enabling and tweaking the size of APCu. Here are the changes we made in the config file.

extension=apcu.so

apc.enabled=1

apc.shm_size=64M

apc.ttl=7200

apc.gc_ttl=3600

apc.enable_cli=0

 

apc.shm_size

This will allocate 64MB from the RAM to APCu for its caching purposes.

apc.enabled

apc.enable enables it for PHP-fpm and  apc.enabled can be set to 0 to disable APCu.

apc.enable_cli

Activates it for command line-PHP like cronjobs.

apc.ttl

The number of seconds a cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry.

apc.gc_ttl

The number of seconds that a cache entry may remain on the garbage-collection list.Set to zero to disable this feature.

 

If you need the different type of configuration like apc.user_ttl, apc.filters etc.. you can also add with above settings.

After the completion of the configuration, save the file and make the symlink.

“sudo ln -s /etc/php/7.0/mods-available/apcu.ini /etc/php/7.0/fpm/conf.d/30-apcu.ini”

Restart php7.1-fpm service

To check the APCu size use this command

“php -i | grep apc.shm_size”

It will results like this

“apc.shm_size => 64M => 64M”

 

Upgrading Rocket Chat

This is a very quick post. Many organizations are using Rocket chat as the slack / IRC alternative.

One important point that is not often documented is the upgrade. We ourselves ran into issues with Node.js errors, Meteror errors etc multiple times.

Here is how we can upgrade without breaking anything.

take a backup of the installation directory

cd /home/rocket
su -l rocket
cp -rfp Rocket.chat backups/date +%F

Assuming that backups are kept in /home/rocket/backups and db backups are in /home/rocket/backups/db

cd backups/db
mongodbump
rm -rf /home/rocket/Rocket.chat

#get the new version

cd /home/rocket
curl -L https://rocket.chat/releases/latest/download -o rocket.chat.tgz
tar xf rocket.chat.tgz
mv bundle Rocket.chat

install dependencies

(cd /home/rocket/Rocket.chat/programs/server && npm install )

All set to start the new server, migrate the dabase etc.

cd /home/rocket/Rocket.chat
node main .js

The last step performs upgrade and maintenance of the db scheme. With most of the versions this method will work.

It is assumed that the user rocket is the user under which Rocket.chat is installed.

Further, the server is running as a service which was done with :

sudo forever-service install -s main.js -e "ROOT_URL=https://chat.agileblaze.net/ MONGO_URL=mongodb://localhost:27017/rocketchat PORT=3000" rocketchat

Urban Airship Push Notification Integration

Push Notification is one of best way to interact with app users. Every mobile developer knows the importance of push notification in mobile apps. Push Notification provides near real-time updation of informations such as news,score updates,messages etc., to users. iOS provides APNS (Apple Push Notification Service) to send push notification data to applications installed on Apple devices. There are many third party push notification services are available  like Parse,Urban airship, Carnival,Push woof etc. The benefits of using third party Push Notification service are,

  • – Reduce Your code.
  • – Save Your  time and effort.
  • – Manage the notifications easily.

This section will explain some simple steps to be followed to send push notification to iOS platform via Urban airship dashboard. The steps are given below.

  • 1. Registration and login
  • 2. Create Your first app in Urban airship
  • 3. Set up your xcode project.
  • 4. Send your first Push Notification

Registration and login

You need to create an account in Urban Airship using an email id and password. There are many pricing plans available. Select a pricing plan or select a free starter account. Click here to view the available account plans. After the successful registration, click manage your apps from Urban Airship dashboard to get started.

Create Your first app in Urban Airship

After the registration is completed, add your first app. You need to specify the following details to create an app.

App Name

The name of your app.

App Icon

Upload an app icon.

Production status

You must select whether your app is in development mode or production mode. When you are setting up development and production apps, you have to configure them for push services. See the APNS Setup documentation for detailed instructions.

Select Platform that will use Urban Airship

Select your platform here. The available platforms are iOS, Android, Windows, Blackberry etc.

After selecting the iOS app platform, save your app.

app fields

Set up your xcode project

You have created an app in previous section. Then you need to set up the xcode project. First, create an xcode project for push notification. Then you have to follow some steps to set up your project. The steps are  explained below.

  • Download Urban airship SDK

Download the latest version of  libUAirship from Urban Airship. Unzip the SDK and add the libUAirship static library and headers into your project. Click here to download the latest version of Urban Airship SDK.

airshipKit

  • Manage Build Settings

In the project’s build settings set “Enable Modules” field to “Yes” and “Link Frameworks Automatically ” to “Yes”.

  • Add Urban Airship SDK

The SDK can be included using the Urban Airship static library(iOS 7+) and Urban Airship Embedded framework(iOS 8+). The static library and embedded framework have different setup procedures.

      Including Urban Airship SDK using Embedded framework(iOS 8+)

-Include Airshipkit

Add  Airshipkit.XcodeProj into your app project in xcode.

-Link against embedded framework

adding framework

Add the Airshipkit.framework file to the Embedded binaries section in the general tab for your project to link against the embedded framework.

Including static library (iOS 7+)

– Search paths

Screen Shot 2016-04-20 at 1.00.23 PM

Ensure that your project’s header search paths under build settings include the Airship directory.

– Linker Flags

Add –objC –lz –lsqlite3 linker flag to prevent “Selector Not Recognized” runtime exceptions and to include linkage to libz and libsqlite3. The linker flag –force_load<path to library>/ libUAirship<version.a> may be used in instances where using the –objC linker flag is undesirable.

Screen Shot 2016-04-20 at 1.01.21 PM

– Link against the static library

In the libraries section in the Build Phases, add the libUAirship.a file to the link binary to link against the static library.

link binary

– Add the Urban Airship resource bundle

Add the UrbanAirshipResources.Bundle file to the Copy Bundle Resources section in the Build Phases tab for your target.

  • Enable Background Notification

You can enable Background notification by enabling Remote notifications of Background mode under the target’s capabilities section.

remoteNotification

  • Create AirshipConfig.plist

To manage your production and development application profiles, the Urban Airship SDK uses a .plist configuration file named AirshipConfig.plist. You can create two application within your Urban Airship account:one for development and one for production. Create  an AirshipConfig.plist and set the following values in your .plist file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>detectProvisioningMode</key>
  <true/>
  <key>developmentAppKey</key>
  <string>Your Development App Key</string>
  <key>developmentAppSecret</key>
  <string>Your Development App Secret</string>
  <key>productionAppKey</key>
  <string>Your Production App Key</string>
  <key>productionAppSecret</key>
  <string>Your Production App Secret</string>
</dict>
</plist>
  • Import the required header files

Import the AirshipKit header files to your application delegate.

Import AirshipKit (Swift)

#import<AirshipKit/ AirshipKit.h>

You must import the individual headers if your application uses the static library.

#import “UAirship.h”

#import “Uaconfig.h”

#import “UAPush.h”
  • Starting Urban Airship Services

Inside your application delegate’s application:didFinishLaunchingWithOptions:method,initialize a shared Uairship instance by calling Uairship takeoff.This will bootstrap the Airship SDK.

-(BOOL)application:(UIApplication*) 
didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{

         [Uairship takeOff:config];
}
  • Retrieving your channel ID

The channel ID is a unique identifier used to target pushes to a specific devices using the Urban Airship API.You can always get the channel ID using the following code.

ObjC:

            NSString *Channelid=[Uairship push].channelID;
            NSLog(@”My channelID:%@”, Channelid);

Swift:

            Let Channelid=Uairship.push().ChannelId
            print(”My channelID:%@”, Channelid)

ChannelID initially comes back as NULL on your apps first run.It will be created and persisted during registration.

  • Enabling User Notifications

By default User notifications are disabled.To enable notification write the following code. Set the user notification types on [Uairship push]. Sounds, alerts and badges are the default types. The library will register to receive notification after the user push notifications are enabled.

[UAirship push].userNotifictionTypes=(UIUserNotificationtypeAlert| UIUserNotificationtypeBadge|UIUserNotificationtypeSound)

[Uairship push].userpushNotificationEnabled=YES;

After all this steps your project’s AppDelegate.m file looks like  below

AppDelegate.m

#import <AirshipKit/AirshipKit.h>

#import “AppDelegate.h”

@interface AppDelegate ()

@end

@implementation AppDelegate

-(BOOL)application:(UIApplication*) 

didFinishLaunchingWithOptions:(NSDictionary*)launchOptions

{
         [Uairship takeOff:config];

         //Set the icon badge to zero

         [[Uairship push]resetBadge];

         [UAirship push].userNotifictionTypes=(UIUserNotificationtypeAlert|   

         UIUserNotificationtypeBadge|UIUserNotificationtypeSound)

         [Uairship push].userpushNotificationEnabled=YES;

}

Send your first push Notification

  • Adding Test Devices

You need to add a list of test devices in Urban airship console before sending your first notification. To setting up test devices, select Audience. You can see a text box for entering  list of device identifiers. You can enter up to 100 device identifier here. After entering the device identifiers save the list.

add audience

To send your first push notification,navigate to Messages Overview ,located under the Messages tab,and click + Messages. You can see a Message box here and type your notification message here. Before sending the notification you have to select the audience and delivery options. The audience are,

All Devices

Single Device

Segments

segments are groups of audience that you can create using combinations of location,tags and lists.

Test Devices

Test devices are predefined devices created by an account administrator.

selecting audience

Select an audience from the list. Then navigate to the delivery section and you can see two options here.

Immediately

Deliver the message immediately.

Schedule

Deliver the messages according to the scheduled time

delivery

If all has been set up correctly,click Confirm and Send Now.

send 1st

You  have sent your first push notification!!!

We use Zeroshell and its awesome :-)

Many of the Free Softwares (GPLed) IMHO (author’s personal opinion) struggles with marketing or reaching to mass audiences. The effort by Zeroshell to reach more audiences by the peculiar “viralware” model is appreciated.

 

We use Zeroshell Firewall on quite a few of our networks and are happy with it.

 

Viralware is a word I just coined ?!

Mosh aka mobile-shell

Mosh_demo_screenshot

Stumbled upon Mobile shell (Mosh) which allows persistent connection over intermittent connections, VPN – WiFi – networking roaming etc. Its quite useful especially when we have tons of nodes across multiple cloud providers & resulting attempts of their attention grabbing. Automating few things in a CRM made us  end up setting up a Postfix mail server after something like more than a decade, got frustrated over the nearly non-existent internet provided by Asianet DSL & all credit of this goes to them.

 

TL;DR Here is a quick guide to get Mosh working on Mac & GNU/Linux flavours.

 

Mosh uses UDP. Yes, you heard it right.

By default it uses 60000 to 61000 for establishing connections. We would need to open up some of these ports, say a subset of this in the fire wall mechanism that we use to get access to the servers.

There is a client & a server

I missed out this part ! Well, we need to install Mosh on the client and the server. (ie apt-get install mosh or yum install mosh on the servers too BOFH.)

On Amazon / AWS / EC2 cloud,

Open up few UDP ports in the security groups. We opened up 10 ports.

On DigitalOcean or any other provider open the ports in your firewall.

Client side installation:

On Mac,  we ran into issues with libprotobuf

> mosh migrate2cloud.com
dyld: Library not loaded: /usr/local/lib/libprotobuf.7.dylib
  Referenced from: /usr/local/bin/mosh-client
  Reason: image not found
Died at /usr/local/bin/mosh line 201. 

The solution is to upgrade Brew (well why shouldn’t one use brew ?)

brew update ; brew upgrade ;  brew remove libprotobuf ; brew install libprotobuf

will do the magic. If not,  we can try

         brew remove mosh ; brew install mosh

as well. If its doesn’t work, RTFM & the FAQ 🙂

Another issue we ran into was the locale & UTF-8 encoding. We fixed it by installing the locale in the client and server and exporting the following environment variable to the bash profile.

# for mosh
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
export MM_CHARSET=utf8
export LC_COLLATE=”en_US.UTF-8″
export LC_TIME=”en_US.UTF-8″
export LC_NUMERIC=”en_US.UTF-8″
export LC_MONETARY=”en_US.UTF-8″
export LC_MESSAGES=”en_US.UTF-8″

You load the environment variables by doing the following in bash.

. ~/.bash_profile   # don’t miss the dot at the beginning

Firewalls, Tunnelling, NAT

It may not work just yet as you may have to deal with NAT traversal and other nasty things. Creating an SSH tunnel can solve these issues.

mosh –ssh=”ssh -4 -R 2222:localhost:22 -i /Users/migrate2cloud/keys/ssh-key”  root@server.com

Reattaching a detached Mosh:mobile-shell is not possible. But we can run screen inside mobile shell.

do pkill mosh-server instead … or pgrep mosh-server -> kill etc

PS: if you use CIRU.org, things may be different for you.

That’s it. DigitalOcean guys have come up with a  nice write up here which is very helpful. There is also an Android client and iOS client in the making. On GNU/Linux I use KDE Konsole & on Mac iTerm : these are 2 good tools that are very useful IMHO.

Your PHP installation appears to be missing the MySQL extension which is required by WordPress

We have came across the following error quite a few times.

 

Your PHP installation appears to be missing the MySQL extension which is required by WordPress

Though it may sound tricky, the error can be quickly fixed by installing missing PHP libraries. This often happens because of the upgrades.

In PHP 7.x we can fix using the following

sudo apt-get install php-mysql

Older PHP versions can be fixed by the following

sudo apt-get install php5-mysqlnd-ms

Don’t forget to restart Apache / Nginx or the relevant web server to load the libraries / modules.

Iozone – file system benchmark quick installation

Iozone – open source file system benchmarking tool is a handy tool which  lets you to inspect  filesystem performance like read, write, rewrite, random read etc etc. Major UNI*X flavours and even Microsfot Windows is supported.

Iozone graph - file system benchmark

This is a quick how to on installation and usage on Redhat flavor Linux & MacOS.

 

 

Installation steps

  1. Download the rpm source fro the Iozone from the following link or enter the follwing command at the command prompt
wget http://www.iozone.org/src/current/iozone-3-338.i386.rpm
  1. install Iozone using the following command
rpm -ivh /path/to/iozone-3-338.i386.rpm

Now the filesystem benchmarking tool is installed. To verify the installation you can find the files of Iozone tool in the directory /opt/iozone/

Plotting graphs from Iozone analysis results

For the plotting of a graph you should ensure that gnuplot is already installed in your machine. Gnuplot is a command-driven opensource function plotting tool. If it isn’t installed you may install it using the following command

yum install gnuplot

After ensuring that you have got gnuplot installed. Lets try plotting the analysis of the Iozone tool on a graph. Here we will analyze the filesystem with in auto mode. Run th iozone command and redirect its output to a file.

/opt/iozone/bin/iozone -a -g 4m > /tmp/test_analysis

In the above command we have set the maximum size of a file for auto mode  to 4mb with -g option. For brief study about Iozone commands use

/opt/iozone/bin/iozone -h

To generate the graph there is another command which is installed with the iozone tool ie Generate_Graphs. To plot the graph use the following commands

/opt/iozone/bin/Generate_Graphs /tmp/test_analysis

A new window will pop up with the plotted graph of the write performance. At the command line if you hit enter then new graph is plotted fro the rewrite performance. Thus there will be graph plotted for many IO performances as you hit enter each time. Evaluate the required IO performances from the set of graphs depending on the application that you are planning to deploy.

 

If you have brew installed, its as simple as

brew install iozone