Best lightweight GIT service for your Raspberry/SOHO server

Not a paid ad.

Finally found what I’ve been looking for, GITEA. Its love at first sight, not only because of the beautiful UI, but because it doesn’t use SO MUCH GODDAMN MEMORY which is expensive in the cloud for such a mundane thing as version management. For the past years, I have had gitlab/bitbucket/stash servers for my personal projects but they used too much memory, considering that the server was used only by 2 people tops (gitlab recommends 4 gigs, runs with 1 gb ram + 3gb swap). The problem with them is that they are written in Java and designed for massive scalability, on the other hand, gitea is a lightweight go service forked from gogs, consuming ~30MB memory with light usage. Also, it is blazing fast, has a great ticket management and a built-in wiki. Its almost as good as Github.

You can get it here: https://gitea.io/

It’s also fairly quick to set up:

  • clone it
  • create a user for it
  • register it as a service (it’s only a single binary so not necessary)
  • edit the config file

GOD BLESS the great guys who designed golang, so people can write efficent applicantions and don’t have to bother with C and memory allocation anymore.

How to offload cpu heavy code to lambda with Nodejs

Nodejs-2-562x309@2x-op

The title, says it all, but basically if you have a small service (in this case written with nodejs) running on a server with limited capabilities, you might run into problems if you want to do processor/memory heavy computations. For this can be a solution to offload the work to lambda, which can scale automatically, and you only have to pay for computation, so basically if you rarely need the computation, instead of renting a server you can do this and save heaps of money.

Talk is cheap, lets build it.

First of all if your dont already have you need the following:

Amazon AWS account

We will create the lambda function with this, and our extension of the application will run here.

Nodejs

Node.js is an open-source, cross-platform JavaScript runtime environment for developing a diverse variety of tools and applications.

You can get it here: download nodejs

NPM

Its for managing javascript packages, if you install nodejs, you will have this.

 

You have to log in to AWS and create a new lambda function:

new_lambda_function_button

You can choose the “Blank template” blueprint.

Name your function give it a description, a choose the Nodejs environment:

function_name_and_description

Insert the following code, it gives back a json when it recieves a request, if the json has an attribute named “data_to_transform” it gives back its value squared.

compute_heavy_task = function(data){
 return data*data;
}

exports.handler = (event, context, callback) => {
 context.succeed(
 {
 "lambda_function_name":"convert_stuff",
 "original_data":event.data_to_transform,
 "transformed_data":compute_heavy_task(event.data_to_transform)
 });
};

Create a role from a policy template and name it:

function_handler_and_role

review your settings:

review

Now you can test it, with the test settings and you’re supposed to get back a json like:

{ 
 lambda_function_name: 'convert_stuff',
 original_data: 500,
 transformed_data: 250000 
}

if your test request looks like:

{
        "data_to_transform":500
}

So in the second part we are going to create a nodejs app which has AWS auth credentials and can call the previously made function.

But first we have to create the credentials. Go to AWS console / IAM -> Users -> Add user.

welcome_to_iam   step1 step2

step3

step4

Save the credentials as a csv file. After clone the folowoing git repository npm install & run it with nodejs.

git clone https://github.com/yodeah/offload_to_lambda
cd offload_to_lambda
npm install

!! edit the conf file, with the neccesary data !!

node app.js