• GitLab, Postgresql and problems on vservers

    After working on a vserver, the little guy needed a reboot. And - who would have thought, after that reboot, GitLab didn’t start correct.

    Without caring about the reasons, I decided to do GitLab a pleasure spending it an update. I should have known better, because I never did an GitLab update without trouble…

    The problem

    Even after the update, GitLab didn’t want to work. A subset of its processes was up and running but navigating to gitlab in my browser, presented me an error 502 and later on an error 500.

    The problem was the combination of postgresql and the vserver, but one step after another:

    Updating GitLab on Ubuntu 14.04

    Let’s start with step one and spend GitLab the latest update. I am using binary Unbuntu packages for some time.

    Only two lines in the terminal, and the everything will be installed rather quickly. It’s a good advice stoping all GitLab instances before sudo service gitlab stop or sudo gitlab-ctl stop, depending on the version.

    Now we can start the installation:

    curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
    sudo apt-get install gitlab-ce

    Don’t be surprised, at first, the gitlab package will be uninstalled. You’ll see a lot of information scrolling along your screen. On my first try, I got an error message, the package couldn’t be installed properly. Don’t ask why, but at my second attempt it worked.

    After the installation we have to reconfigure GitLab to transfer the old settings:

    sudo gitlab-ctl reconfigure

    Done! Or are we?

    Error 502 - Getting Postgresql to work

    After the installation I got an error 502 when looking in the browser. Having a look at gitlab-ctl status told me, everything is fine.

    I didn’t trust the status, so I started the GitLab selftest:

    sudo gitlab-rake gitlab:app:check

    At first everything looked fine, but then the test was aborted due a fatal error. Postgresql couldn’t be accessed because there wasn’t any socket file under tmp. So, to the Googles! I found some advices, one should create symbolic links etc. But then I found the real problem.

    Postgresql, VServer and RAM

    It seems like Postgresql is reserving 25% of the system memory by default. This will probably fail, running on a vserver. Looking at the logfile (/var/log/gitlab/postgresql/current) confirmed this theory.

    GitLab comes with its own instance of Postgresql and so it also have an own config, which is included in the main GitLab config at /etc/gitlab/gitlab.rb.

    Depending on the documentation of GitLab you have to set postgresql['shared_buffers'] = "100MB". I did, but Postgresql didn’t care. The logs said something about shmmax. So I searched within the config and found something. I set the value down to: postgresql['shmmax'] = 10179869184

    After changes on that config, you have to reconfigure GitLab:

    sudo gitlab-ctl reconfigure

    After that I restarted Gitlab, too, just to make sure Postgresql gets the changes.

    sudo gitlab-ctl restart

    And here we are! A socket file at /tmp. Hurray! Launching my browser, heading towards GitLab… and… Error 500. Great.

    Error 500

    Because everything was up and running I started the selftest again, hoping I will get some more information this time.

    sudo gitlab-rake gitlab:app:check

    And tada! The datebase has to be migrated.

    sudo gitlab-rake db:migrate RAILS_ENV=production

    Running the test again confirms: everything is find. So let’s restart GitLab again:

    sudo gitlab-ctl restart

    Starting the browser and we’ll see a beautiful login screen. Nice! We can also use git to push and pull.

    Let’s hope the next update will be easier.

    Update

    After restarting the server, the problem occured again. Great. This Blogpost helped.

    Sources:

    https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master#postgres-error-39-fatal-could-not-create-shared-memory-segment-cannot-allocate-memory-39

    https://gitlab.com/gitlab-org/gitlab-ce/issues/719

    Read full post
  • Kirby Podcast Plugin

    I mentioned it one time or another, I am currently working on a little podcast show. For that, I wrote a plugin for my favorite CMS, Kirby.

    Well, at first I decided to quickly set up a WordPress site and install a podcast plugin, to get the thing up and running fast.

    But then I decided not to do so. The theme I bought wasn’t compatible with the podcast plugin and a lot of new security issues spoke against a quick and carefree WordPress Podcast setup.

    So I switched to Kirby and started building a theme. I don’t want to do much work on the site at the current time. The most important thing is the podcast. And most of the people will subscribe to it using their favorite podcast client.

    Anyway, something really important was missing. An appropriate RSS-feed containing all the necessary fields for iTunes and the other clients around. Using just a standard RSS-feed won’t work.

    So I sat down and started writing a plugin. The plugin serves a RSS-feed, in the form I need it for iTunes. And it analyzes all MP3-files I uploaded to the post. So duration and size will be determined and transfered to iTunes.

    I set up a page for the plugin and put the sources on GitHub. So, if you like to use Kirby as your CMS for your podcast, go ahead and grab the plugin.

    Oh btw, I hope the new site of my podcast will be only soon. Although it will be german only, sorry.

    Read full post
  • Sublime Text for JavaScript developers

    I’ve been searching for some time now, to find the best Sublime Text plugins which help me write JavaScript code. And it seems like I’ve found a good combination.

    JavaScript Ultimate

    JavaScript Ultimate is the heart of my setup. It comes with an outstanding autocomplete for functions and variables. This plugin is an extended language definition, so it replaces the JavaScript language definition comming with sublime.

    Get the Plugin

    Go To Definition

    You can easily jump to a definition of a function or anything else within Sublime Text, by pressing cmd+r and starting to type. Or you can choose an entry from the list.

    Go To Definition makes it even more simpler. Just put your cursor on a function-call and press alt+g. The plugin will now jump to the related function/method. The best thing is, this works cross-file.

    Get the Plugin

    JavaScript Snippets

    The name should speak for itself. It is a collection of usefull JavaScript snippets. Very helpful.

    Get the Plugin

    Alignment

    I like my code to be in shape. So Alignment is mandatory for me. Marked sections will be aligned, like so:

    {
    hallo: welt,
    hallihallo: universum
    }

    will become:

        {
            hallo     : welt,
            hallihallo: universum
        }

    Get the Plugin

    Bracket Highlighter

    The Bracket Highlighter helps you get a better overview. It works with a lot of languages and shows code blocks next to the line numbers.

    Get the Plugin

    Sublime Linter

    Sublime Linter by itself doesn’t do a lot. You’ll need some other plugins. I use JSHint and Annotations.

    If you’re writing JavaScript code, you should know JSHint. This linter shows errors and warnings right when I make them. You can configure JSHint being more or less strict. In case of JSHint you’ll need the binaries, which you have to install by yourself, because the plugin comes without them.

    Annotation helps me getting an overview of all my TODOs and stuff like that. It marks comments containing certain words, which you can freely define. Those can be marked as a warning or error. And you can even get a cross-file-report, if you like.

    Get the Plugin
    Plugins for Sublime Linter

    Conclusion

    I am quite happy with my current setup. Especially with the autocomplete. Try it out and let me know, if you know other plugins I have to look at.

    I’ve some more plugins doing some work for me, which you can find in my older posts.

    Read full post
  • Thank god, it’s Monday!

    Now you’re looking at me, like I’ve made you a weird offer, right? If you’re like many others, Monday is probably not your favorite day of the week. But this might change.

    At least a little bit.
    Let’s be honest, it’s all about starting your day the right way, isn’t it? So, let’s try to improve our start into the week. Introducing my new newsletter: "Monday".

    Every Monday you’ll get a nice, friendly newsletter full of interesting, positive stuff about what we call the world wide web.

    Read about what was and is going on. Get some interesting articles about web dev, web design and things around. And if I find something really interesting apart from that topics, that stuff may be included, too.

    Along with the written word, you’ll even get a Monday morning soundtrack, which will grow from week to week and hopefully put a smile on your face.

    So let your Monday morning start positive and subscribe to my newsletter. One mail a week, that’s it. No hidden fees, no spam, no surprising buy-this-mails. Just some nice, friendly content, making you start the new week in a good way.

    Read full post
  • Code faster using Sublime Text and Gists

    If you develop websites or software, you now that procedures and code fragments may be reused from time to time. As a developer you should always try to avoid those repetitions.

    The first step is independent of what editor you use, or what kind of thing you develop. The first step should always be, to rethink your code. If you repeat parts of your code over and over, you should always ask yourself if that part shouldn't be better put in a method or function.

    The more repetitions you have, the more inflated your code is, the more difficult it is to maintain it. If you then have to change something, you may need to this not only one time but again and again. And if you miss just one part, that may have uncertain consequences.

    Well, okay… Sometimes you just repeat yourself. If you want to or not. For example when you start a new project. You need that html5 template, that javascript function or your personal css-template.

    Because of this, the smart developer has a collection of those templates called snippets.

    Snippets

    You can organize your snippets in various ways. As a simple text file anywhere on your hard drive or dropbox folder. Using an application doing the work for you. And Sublime Text by itself has a snippet functionality included.

    Sublime Text Snippets

    Those snippets have a huge advantage, you can set shortcuts or use autocomplete to insert them. And you can use placeholders within snippets which are reachable via the tab key.

    The big disadvantage: These snippets are stored in your Sublime Text user directory. You don't really have an overview. And it's hard work to sync them.

    But I want my snippets to be available anywhere and regardless of what editor I use.

    GitHub Snippets

    GitHub has an own system for snippets, called Gists. If you have a GitHub account you can create and manage gists.

    After trying several methods I sticked with Gists.

    The biggest advantage: I can use them anywhere. I do only need a browser and access to the web. Simply login to GitHub and here they are.

    And beside my own Gists I can also have a look at public Gists of other users. So if I need a snippet to solve a certain problem, I can just perform a search and (may) get a more or less long list of solutions. As known from GitHub I can star Gists or fork them to create my own version.

    If I don't want to share mit snippet with others, I can create a private one. Nobody will be able to access it.

    Sublime Text Gists

    As we know, there is a Sublime Text Plugin for every possible scenario. Yes, you heard right! For EVERY scenario, don't argue with me! ;)

    So there is a plugin for Gists: https://github.com/condemil/Gist

    You need GitHub account (of course) otherwise you cannot create Gists. To use the plugin, you have to create an Access Token which is described in the README of the plugin step by step.

    Setup

    After you created your Token, you just have to add it to your Sublime Text Settings. Just go to: Sublime Text > Preferences > Package Settings > Gist > Settings User. And insert your Token:

    {
        "token": "1234567890"
    }

    Using the plugin

    You can use the plugin sublimelike via shortcut or cmd+shift+p. Just enter gist and you'll get a list of functions. Here you can create Gists (public and private), add Gists as new file or insert them into the currently open file.

    If you choose Insert Gist you'll see a list of you own Gists and those you stared. You can limit the list by starting to type and/or you can navigation with the arrow-keys.

    Creation of Gists

    You can create Gists right from Sublime Text or via web. I prefer sublime text.

    I always try to name my Gists clearly. For that I use a simple syntax: I start with the code language, like this:
    [html], [sh], [scss] that way I can quickly see the kind of code and limit my search to a certain language.

    Share

    Sharing it great! Because of that, most of my Gists are public. Maybe you have some interesting Gists on your own. Post a link in the comments if you like or share them via Twitter.

    Read full post