Installing Mako Server as a service (aka daemon) on Linux is straightforward. The following example shows how to create a dedicated user for the Mako Server and create a boot script that starts the Mako Server when Linux starts. This script also enables you to start/stop the service from the command line.
If you want to quickly install the Mako Server as a Linux daemon, you may use the cloud server installation script if you are installing the server on an X86 type CPU.
Running the Mako Server in the background is super easy, all you have to do is to add the -d switch:
mako -d additional-commands
Starting the Mako Server in the background as shown above makes the server run until Linux reboots. We can automate the Mako Server startup when Linux powers on by either creating an init.d script or a systemd script. This tutorial focuses on creating an init.d script. If you prefer systemd and if you have Ansible experience, check out the SharkTrust Installer, which shows how to automatically install the Mako Server and how to auto start the server using systemd.
Note, all commands below must be run as user root. If you are not root, you can become root by using the command su or sudo sh.
First, we need to download and install the Mako Server. You can skip this step if you have already copied Mako Server to your /usr/bin directory. The following commands download Mako Server for x86 (32 or 64) bit. For other platforms, download the appropriate version or cross compile the source for your target platform.
Copy the following commands and paste into your terminal window.
The next step is to create a dedicated user for the Mako Server. We will use the name 'mako' as the Linux user. You can choose any username or simply run the server under your existing user account. However, you must modify the service script (downloaded in the next step) if you use a username other than 'mako'.
You should now have a new user with the home directory /home/mako. We are now ready to install the Mako Server's boot script. This script starts the Mako Server as a Linux service (aka daemon) -- that is, the server runs in the background.
Copy the following instructions into your terminal window to install the startup script.
You should now be able to start and stop the Mako Server as a background process from the command line:
Although you can start and stop the server from the command line, the server will not start if you reboot your Linux computer. For this to work, the following command must be run:
If you started Mako Server as instructed above, you will get a 404 not found response if you visit the server using a browser. We need to install at least one LSP application in the server. The following example shows how to create one app that simulates a standard web server's www directory.
Run the following command in your console Window:
You should now be running as the user 'mako' and be in the /home/mako directory. The next step is to create a mako configuration file that loads one app. You can use any editor when creating the configuration file. We are using the 'nano' editor in the following example. If you get an error when running nano, install nano as follows: apt-get install nano.
When nano is running, copy the following and paste into the nano editor.
Using the nano editor, modify the username "mako" to your username and the password "123456" to a more suitable password. Press Ctrl-X and save the file (Y). You should now be back at the command prompt.
The above configuration file sets up one root application using the path 'www' (that is /home/mako/www). We must create this directory before restarting the server. Type the following command at the Linux command prompt.
We can now restart the server. The two following commands exit user mako (back to root) and restart the server.
You will still get a 404 page if you visit the server using a browser. What we need is an index page in the new www directory.
Create index.lsp in the www directory.
Map/mount the server using WebDAV if the Mako Server runs on an online VPS (cloud server)
To map/mount the online server as a file system, use the URL: http://server-address/dav/. In Windows, you can go to Map Network Drive and enter the URL to map the online server as a drive in Windows. See the WebDAV information page for the BarracudaDrive product for more information on how to map/mount a WebDAV drive. The above Mako Server configuration script (mako.conf) enabled WebDAV for your application. The WebDAV username/password (default mako/123456) is what you put into the modified Mako Server configuration script.
When you have mapped/mounted WebDAV, use any editor on your host computer (PC) and open/create a new file on the mapped/mounted drive.
The following example shows how to do this on Windows using Notepad. The online server is mapped as 'Z:'.
Copy the following content into the editor (index.lsp) and save the file.
You should now see "Hello Browser" if you visit your home page using your browser.
Function trace would normally print to the console, but you have no console when the server runs as a background service. The Mako Server inserts the information printed to the console into the file mako.log when the server runs as a background service. This log can also be viewed in real time if the TraceLogger is enabled. The TraceLogger was enabled in the above Mako Server configuration script. Navigate to http://servername/rtl/tracelogger/ and login using the credentials you entered when you modified the mako configuration file. You should see the following:
Notice how the message "Hello Trace" and the line number is printed each time you navigate (using a different browser window) to your main index page.
We stored the passwords in clear text in the above Mako Server configuration file (mako.conf). You can also store the passwords as an MD5 hash. The MD5 hash must be computed as explained in the Barracuda App Server manual: Storing passwords as a hash value.
You may use the following LSP script to simplify the calculations. Copy the following content and paste it into an LSP page that you can run on your server instance.
When you run the page, enter the following:
http://servername/pagename.lsp?u=mako&p=123456
'mako' and '123456' must be substituted with your own credentials.
Executing the page with the above credentials produces the following result:
mako={"072fa416feb977c8c2d7464e50a32122"}
Copy the produced result and paste into mako.conf:
users = { mako={"072fa416feb977c8c2d7464e50a32122"} }
The tutorial Setting up an IoT Broker explains how to install the Mako Server on a low cost online VPS.
Dive deep into our treasure trove of embedded web server and IoT tutorials designed for enthusiasts like you. Yet, if deadlines loom or challenges arise, remember our experts are on standby. With Real Time Logic, you have the freedom to learn and the assurance of expert support when you need it. Let's bring your project to fruition your way.
Expedite your IoT and edge computing development with the "Barracuda App Server Network Library", a compact client/server multi-protocol stack and toolkit with an efficient integrated scripting engine. Includes Industrial Protocols, MQTT client, SMQ broker, WebSocket client & server, REST, AJAX, XML, and more. The Barracuda App Server is a programmable, secure, and intelligent IoT toolkit that fits a wide range of hardware options.
SharkSSL is the smallest, fastest, and best performing embedded TLS stack with optimized ciphers made by Real Time Logic. SharkSSL includes many secure IoT protocols.
SMQ lets developers quickly and inexpensively deliver world-class management functionality for their products. SMQ is an enterprise ready IoT protocol that enables easier control and management of products on a massive scale.
SharkMQTT is a super small secure MQTT client with integrated TLS stack. SharkMQTT easily fits in tiny microcontrollers.
An easy to use OPC UA stack that enables bridging of OPC-UA enabled industrial products with cloud services, IT, and HTML5 user interfaces.
Use our user programmable Edge-Controller as a tool to accelerate development of the next generation industrial edge products and to facilitate rapid IoT and IIoT development.
Learn how to use the Barracuda App Server as your On-Premises IoT Foundation.
The compact Web Server C library is included in the Barracuda App Server protocol suite but can also be used standalone.
The tiny Minnow Server enables modern web server user interfaces to be used as the graphical front end for tiny microcontrollers. Make sure to check out the reference design and the Minnow Server design guide.
Why use FTP when you can use your device as a secure network drive.
PikeHTTP is a compact and secure HTTP client C library that greatly simplifies the design of HTTP/REST style apps in C or C++.
The embedded WebSocket C library lets developers design tiny and secure IoT applications based on the WebSocket protocol.
Send alarms and other notifications from any microcontroller powered product.
The RayCrypto engine is an extremely small and fast embedded crypto library designed specifically for embedded resource-constrained devices.
Real Time Logic's SharkTrust™ service is an automatic Public Key Infrastructure (PKI) solution for products containing an Embedded Web Server.
The Modbus client enables bridging of Modbus enabled industrial products with modern IoT devices and HTML5 powered HMIs.