Skip to content

Run Fastlane as a Daemon

fastlaneIcon

If you’re a mobile developer and have a need to automate your process then Fastlane is for sure something you should at least be aware of. It allows automation by bringing together open source command line tools and it does so in a fairly elegant and very efficient way. The git repo can be found here:
https://github.com/fastlane/fastlane

This is a short post on automating Fastlane using a Daemon. If you’re simply trying to automate your lanes then having a Daemon that does that can be a very fast and powerful option to have. I am not going to go into details about Daemons, how they work etc…, plenty of resource on the internet can help you with that if needed.

Below I am going to list the steps I took to get this done.

First thing I went ahead and created a shell script that would run the needed lane. In our case we would run it manually like so:

fastlane shipBeta

In ~/myApp I created beta.sh:

Now I want to execute the beta.sh using a Daemon. My need was to have it run once a day at a specific time. I decided to use a daemon and not use an agent because I wanted to run it as root for other needs I have. We can get the daemon going by creating an xml file called com.myApp.shipBeta.plist in /Library/LaunchDaemons:

This xml file tells the daemon to run the beta.sh script every day at 18:30 (6:30 pm). It will dump any error log to **/tmp/com.myApp.launched.err** and dump output to **/tmp/com.myApp.launched.out**. Tailing these logs can be helpful especially to debug possible problems while setting up the Daemon. (for example: tail -f /tmp/com.myApp.launched.err -n 1000)

To help with some occasional environment errors during the execution of beta.sh I made sure to have the environment daemon:

When all of this is done go ahead and load the deamons with:

launchctl load -w com.myApp.shipBeta.plist

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *