{"id":2139,"date":"2016-11-18T16:35:48","date_gmt":"2016-11-18T15:35:48","guid":{"rendered":"https:\/\/denbeke.be\/blog\/?p=2139"},"modified":"2016-11-18T16:42:32","modified_gmt":"2016-11-18T15:42:32","slug":"running-gogs-go-git-service-as-a-service-on-macos-os-x-server","status":"publish","type":"post","link":"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/","title":{"rendered":"Running Gogs (Go Git Service) as a service on macOS X server"},"content":{"rendered":"<p><a href=\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/attachment\/favicon-ico\/\" rel=\"attachment wp-att-2142\"><img loading=\"lazy\" class=\"alignright size-full wp-image-2142\" src=\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2016\/11\/favicon.ico.png\" alt=\"favicon.ico\" width=\"143\" height=\"152\" \/><\/a>This guides explains how you can run <a href=\"https:\/\/gogs.io\" target=\"_blank\">Gogs<\/a> git server as a service on your Mac using <em>launchd<\/em>.<\/p>\n<h3 id=\"command-line-tools\">Command line tools<\/h3>\n<p>First you need to install Xcode from the <a href=\"https:\/\/itunes.apple.com\/be\/app\/xcode\/id497799835?l\" target=\"_blank\">Mac App Store<\/a>. Once installed, you also need the <em>Command Line Tools<\/em>, you can initiate the download process by executing <code>$ xcode-select --install<\/code> in the Terminal.<\/p>\n<p>The command line tools include Git.<\/p>\n<h3 id=\"mysql-or-postgresql-server\">MySQL or PostgreSQL server<\/h3>\n<p>You also need a database server for Gogs. You can install MySQL using MacPorts. A good tutorial can be found <a href=\"https:\/\/trac.macports.org\/wiki\/howto\/MySQL\">here<\/a>.<\/p>\n<p>You can alternatively run MariaDB instead of MySQL. <a href=\"https:\/\/denbeke.be\/blog\/webdevelopment\/installing-mamp-mac-os-x-apache-mariadb-php-using-macports\/\" target=\"_blank\">My blogposts about MAMP (using MacPorts)<\/a> includes a section about MariaDB.<\/p>\n<h3 id=\"installing-and-configuring-gogs\">Installing and configuring Gogs<\/h3>\n<p>I could try to write a good tutorial here, but the developers of Gogs already made a very nice tutorial about how you can install and configure Gogs. <a href=\"https:\/\/gogs.io\/docs\/installation\/install_from_binary\" target=\"_blank\">Read it here<\/a>.<\/p>\n<h3 id=\"launchd-config\">Launchd config<\/h3>\n<p>Create a <em>launchd<\/em> config file <code>~\/Library\/LaunchAgents\/io.gogs.web.plist<\/code><\/p>\n<pre><code>&lt;?xml version=\u201d1.0\" encoding=\u201dUTF-8\"?&gt;\r\n&lt;!DOCTYPE plist PUBLIC \u201c-\/\/Apple Computer\/\/DTD PLIST 1.0\/\/EN\u201d \u201chttp:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd\"&gt;\r\n&lt;plist version=\u201d1.0\"&gt;\r\n    &lt;dict&gt;\r\n        &lt;key&gt;Label&lt;\/key&gt;\r\n        &lt;string&gt;io.gogs.web&lt;\/string&gt;\r\n        &lt;key&gt;EnvironmentVariables&lt;\/key&gt;\r\n        &lt;dict&gt;\r\n            &lt;key&gt;HOME&lt;\/key&gt;\r\n            &lt;string&gt;\/Users\/mathias&lt;\/string&gt;\r\n        &lt;\/dict&gt;\r\n        &lt;key&gt;ProgramArguments&lt;\/key&gt;\r\n        &lt;array&gt;\r\n            &lt;string&gt;sh&lt;\/string&gt;\r\n            &lt;string&gt;-c&lt;\/string&gt;\r\n            &lt;string&gt;cd \/Users\/mathias\/Sites\/gogs; .\/gogs web&lt;\/string&gt;\r\n        &lt;\/array&gt;\r\n        &lt;key&gt;UserName&lt;\/key&gt;\r\n        &lt;string&gt;mathias&lt;\/string&gt;\r\n        &lt;key&gt;RunAtLoad&lt;\/key&gt;\r\n        &lt;true\/&gt;\r\n        &lt;key&gt;KeepAlive&lt;\/key&gt;\r\n        &lt;true\/&gt;\r\n        &lt;key&gt;WorkingDirectory&lt;\/key&gt;\r\n        &lt;string&gt;\/Users\/mathias&lt;\/string&gt;\r\n        &lt;key&gt;StandardOutPath&lt;\/key&gt;\r\n        &lt;string&gt;\/Users\/mathias\/Sites\/gogs\/launchd.log&lt;\/string&gt;\r\n        &lt;key&gt;StandardErrorPath&lt;\/key&gt;\r\n        &lt;string&gt;\/Users\/mathias\/Sites\/gogs\/launchd_error.log&lt;\/string&gt;\r\n    &lt;\/dict&gt;\r\n&lt;\/plist&gt;<\/code><\/pre>\n<p>You can now start and stop Gogs using the following commands:<\/p>\n<pre><code>$ launchctl load ~\/Library\/LaunchAgents\/io.gogs.web.plist\r\n$ launchctl unload ~\/Library\/LaunchAgents\/io.gogs.web.plist<\/code><\/pre>\n<h3 id=\"https-proxy\">HTTPS proxy<\/h3>\n<p>I then run <a href=\"https:\/\/caddyserver.com\">Caddy<\/a> in front of Gogs to use Caddy&#8217;s built-in automated HTTPS support. My <code>git<\/code> subdomain is then a reverse proxy to Gogs:<\/p>\n<pre><code>git.my-domain.com {\r\n    proxy \/ http:\/\/localhost:3000\r\n}<\/code><\/pre>\n<p>More info about running Caddy as a service can be found in this blogpost: <a href=\"https:\/\/denbeke.be\/blog\/software\/running-caddy-as-a-service-on-macos-os-x-server\/\" target=\"_blank\">Running Caddy as a service on macOS X server<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guides explains how you can run Gogs git server as a service on your Mac using launchd. Command line tools First you need to install Xcode from the Mac App Store. Once installed, you also need the Command Line Tools, you can initiate the download process by executing $ xcode-select &#8211;install in the Terminal. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[235,227,161],"tags":[210,232,151,186],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.6.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Running Gogs (Go Git Service) as a service on macOS X server &ndash; DenBeke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running Gogs (Go Git Service) as a service on macOS X server &ndash; DenBeke\" \/>\n<meta property=\"og:description\" content=\"This guides explains how you can run Gogs git server as a service on your Mac using launchd. Command line tools First you need to install Xcode from the Mac App Store. Once installed, you also need the Command Line Tools, you can initiate the download process by executing $ xcode-select --install in the Terminal. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/\" \/>\n<meta property=\"og:site_name\" content=\"DenBeke\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-18T15:35:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-11-18T15:42:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2016\/11\/favicon.ico.png\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/denbeke.be\/blog\/#website\",\"url\":\"https:\/\/denbeke.be\/blog\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/denbeke.be\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2016\/11\/favicon.ico.png\",\"width\":143,\"height\":152},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/#webpage\",\"url\":\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/\",\"name\":\"Running Gogs (Go Git Service) as a service on macOS X server &ndash; DenBeke\",\"isPartOf\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/#primaryimage\"},\"datePublished\":\"2016-11-18T15:35:48+00:00\",\"dateModified\":\"2016-11-18T15:42:32+00:00\",\"author\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/denbeke.be\/blog\/software\/running-gogs-go-git-service-as-a-service-on-macos-os-x-server\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\",\"name\":\"Mathias Beke\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/denbeke.be\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/015ba35e6ce4f5859e3888ca99807575?s=96&d=mm&r=g\",\"caption\":\"Mathias Beke\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2139"}],"collection":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/comments?post=2139"}],"version-history":[{"count":3,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2139\/revisions"}],"predecessor-version":[{"id":2143,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2139\/revisions\/2143"}],"wp:attachment":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/media?parent=2139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/categories?post=2139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/tags?post=2139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}