Package Manager Translation for Meilix

There are many Linux distros and all of them use variety of different package managers. So a particular user of that specific Linux distro is familiar with that distro package manager commands only. Due to which when that user is out at a event or someplace else and require to install or remove or update package using the commands he is familiar with, he may get errors in doing so if that distro doesn’t have a package manager that he is familiar with. To overcome this problem we can have a solution of adding package manager command translating functionality to Meilix. To translate the commands of package manager like pacman, apt, yum, zypper we have build translation modules for each. To install these modules we first check the Linux distro and map it to the package manager it is using. For this we write the following script. declare -A osInfo; osInfo[/etc/redhat-release]=yum osInfo[/etc/arch-release]=pacman osInfo[/etc/gentoo-release]=emerge osInfo[/etc/SuSE-release]=zypp osInfo[/etc/debian_version]=apt-get   Then after checking the native package manager it copy the modules required for that packet manger to the bin and makes them executable.These modules can be called by the names of the packet manager not available on These modules can be called by the names of the packet manager not available on system. The module reads the arguments and convert command according to it. Like for pacman to apt module, a simple pacman command to install a app is Now, the pacman is a module called from bin using two arguments and these two arguments use a switch statement are converted. Example of commands in ubuntu / debian based system using apt but the user was familiar with pacman Installing package: pacman -S PACKAGE Gets translated to: apt install PACKAGE Remove package: apt install PACKAGE Gets translated to: apt remove PACKAGE Update software database : pacman -Syy Gets translated to: apt update Show updatable packages: pacman -Qu Gets translated to: apt list --upgradable Update all: pacman -Syu Gets translated to: apt upgrade   Mew ensures the cross distro package manager command compatibility by providing translations which is a helpful tool especially at events where users may find it difficult to operate system if he cannot install or add the specific package he requires at that time. Mew helps in making the user experience better as the user don’t have to struggle with the package manager commands he is not familiar with. contribute to the project by forking: https://github.com/fossasia/mew

Continue ReadingPackage Manager Translation for Meilix

Keep your node server running using PM2

The open event webapp generator is a node projects (using an express server), and a copy of it runs all the time on my personal DigitalOcean box (other than our heroku instance). On a service like Heroku, the platform manages the task of bringing your server process up. But on, say a Linux distro on the DO box, you have to manually do npm run server to be able to run the server. While that is all good, it is a foreground shell process, which means, you will lose the node server, when you log out (or your internet connection into the ssh breaks). So we need to be able to keep the process running in the background. The way we do it in bash on Unix, is that we can do either of the following npm run server& The "&" at the end means it will make a background fork of this task. Or if you've already started it without it, you can also do the following. npm run server # starts in foreground #Press Ctrl + Z, this pauses task and frees the shell bg 1 # sends task no 1 to background thread. Again, both these are hacky methods, will work only on Unix OSs, and are not really recommended for production. For production, we need a Process Manager, for Node.js the best we can get is pm2 - purpose built process manager for node. Install pm2 first sudo npm install -g pm2 Using pm2, we can start any process that can be started with node. We can start the app.js script like this pm2 start src/app.js Also, pm2 can run npm tasks too like pm2 start npm -- start Pm2 has a pretty status message display window. And we can start, stop, pause, kill and/or restart any process.  

Continue ReadingKeep your node server running using PM2