Deploying a haskell application (not a webapp)

Hi I have created an application using cabal that now installs fine and runs fine on my dev machine. I now want to deploy this application onto a separate server. This is not a webapp. Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved). Any advice on the neatest way to do this? Thanks Alan

On Sat, Dec 13 2014, "Alan Buxton"
Hi
I have created an application using cabal that now installs fine and runs fine on my dev machine.
I now want to deploy this application onto a separate server. This is not a webapp.
So, what kind of application is it? What are your requirements? It would certainly help to know a bit more about what you are trying to do.
Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved).
What have you tried searching for?
Any advice on the neatest way to do this?
It all depends. Do you want to share your app with others? Are you researching how you might deploy a Haskell app to some production scenario? GHC compiled binaries statically link haskell libraries and link against some dynamic libraries (primarily C libs). The binary can be copied between machines of the same architecture (assuming dynamically linked libraries are satisfied on the target machine). You can see runtime dependencies of your app: $ ghc --make ./Main.hs not a dynamic executable $ ldd ./Main linux-vdso.so.1 (0x00007fff201fc000) libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fcc42fe6000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcc42ce5000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fcc42adc000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcc428d8000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcc426c2000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcc42318000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fcc420fb000) /lib64/ld-linux-x86-64.so.2 (0x00007fcc43296000) For the most simple case you can just copy your app to a target machine: $ scp ./app me@host: Regards, -- Christopher Reichert irc: creichert gpg: C81D 18C8 862A 3618 1376 FFA5 6BFC A992 9955 929B

On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton
I now want to deploy this application onto a separate server. This is not a webapp.
Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved).
Looks like there are some assumptions probably based on familiarity with some other language + toolchain. Of what is the haskell analogue you're looking for? -- Kim-Ee

Hi thanks for the input so far.
See attached a zipfile of a simplified version of the app. It runs locally on my dev machine and I want to be able to run it on a separate server. I don’t want to share the app with anyone else.
If I do “cabal install” with this particular application then it creates an executable at ~/.cabal/bin/app1
If I copy that file onto the target server then I get the following output:
$ ./app1 fred
Hi fred
Time now is 2014-12-13 17:27:21.764048 UTC
app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does not exist (No such file or directory)
So sort of works but in particular the file attachment piece doesn’t work.
From: Beginners [mailto:beginners-bounces@haskell.org] On Behalf Of Kim-Ee Yeoh
Sent: 13 December 2014 16:53
To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell
Subject: Re: [Haskell-beginners] Deploying a haskell application (not a webapp)
On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton

I use Nix package manager for binary deployment of Haskell applications,
and it works great. Feel free to email me directly if you're interested in
the specifics.
On Dec 13, 2014 12:34 PM, "Alan Buxton"
Hi thanks for the input so far.
See attached a zipfile of a simplified version of the app. It runs locally on my dev machine and I want to be able to run it on a separate server. I don’t want to share the app with anyone else.
If I do “cabal install” with this particular application then it creates an executable at ~/.cabal/bin/app1
If I copy that file onto the target server then I get the following output:
$ ./app1 fred
Hi fred
Time now is 2014-12-13 17:27:21.764048 UTC
app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does not exist (No such file or directory)
So sort of works but in particular the file attachment piece doesn’t work.
*From:* Beginners [mailto:beginners-bounces@haskell.org] *On Behalf Of *Kim-Ee Yeoh *Sent:* 13 December 2014 16:53 *To:* The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell *Subject:* Re: [Haskell-beginners] Deploying a haskell application (not a webapp)
On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton
wrote: I now want to deploy this application onto a separate server. This is not a webapp.
Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved).
Looks like there are some assumptions probably based on familiarity with some other language + toolchain.
Of what is the haskell analogue you're looking for?
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

I'd think the details would be of general interest, why don't write an
article/blogpost?
Am 13.12.2014 18:50 schrieb "Ryan Trinkle"
I use Nix package manager for binary deployment of Haskell applications, and it works great. Feel free to email me directly if you're interested in the specifics. On Dec 13, 2014 12:34 PM, "Alan Buxton"
wrote: Hi thanks for the input so far.
See attached a zipfile of a simplified version of the app. It runs locally on my dev machine and I want to be able to run it on a separate server. I don’t want to share the app with anyone else.
If I do “cabal install” with this particular application then it creates an executable at ~/.cabal/bin/app1
If I copy that file onto the target server then I get the following output:
$ ./app1 fred
Hi fred
Time now is 2014-12-13 17:27:21.764048 UTC
app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does not exist (No such file or directory)
So sort of works but in particular the file attachment piece doesn’t work.
*From:* Beginners [mailto:beginners-bounces@haskell.org] *On Behalf Of *Kim-Ee Yeoh *Sent:* 13 December 2014 16:53 *To:* The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell *Subject:* Re: [Haskell-beginners] Deploying a haskell application (not a webapp)
On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton
wrote: I now want to deploy this application onto a separate server. This is not a webapp.
Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved).
Looks like there are some assumptions probably based on familiarity with some other language + toolchain.
Of what is the haskell analogue you're looking for?
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

I'd be interested in reading that and am sure others would be too! On 12/13/14 1:01 PM, Norbert Melzer wrote:
I'd think the details would be of general interest, why don't write an article/blogpost?
Am 13.12.2014 18:50 schrieb "Ryan Trinkle"
mailto:ryan.trinkle@gmail.com>: I use Nix package manager for binary deployment of Haskell applications, and it works great. Feel free to email me directly if you're interested in the specifics.
On Dec 13, 2014 12:34 PM, "Alan Buxton"
mailto:alanbuxton@gmail.com> wrote: Hi thanks for the input so far.
See attached a zipfile of a simplified version of the app. It runs locally on my dev machine and I want to be able to run it on a separate server. I don’t want to share the app with anyone else.
If I do “cabal install” with this particular application then it creates an executable at ~/.cabal/bin/app1
If I copy that file onto the target server then I get the following output:
$ ./app1 fred
Hi fred
Time now is 2014-12-13 17:27:21.764048 UTC
app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does not exist (No such file or directory)
So sort of works but in particular the file attachment piece doesn’t work.
*From:*Beginners [mailto:beginners-bounces@haskell.org mailto:beginners-bounces@haskell.org] *On Behalf Of *Kim-Ee Yeoh *Sent:* 13 December 2014 16:53 *To:* The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell *Subject:* Re: [Haskell-beginners] Deploying a haskell application (not a webapp)
On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton
mailto:alanbuxton@gmail.com> wrote: I now want to deploy this application onto a separate server. This is not a webapp.
Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved).
Looks like there are some assumptions probably based on familiarity with some other language + toolchain.
Of what is the haskell analogue you're looking for?
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org mailto:Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org mailto:Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Duly noted! I didn't think an in-depth discussion of Nix would be on-topic
for this mailing list, but it looks like there's more interested than I
thought. When I get the chance to put something together, I'll make sure
to send out a link here.
On Sun, Dec 14, 2014 at 4:21 AM, Thomas Jakway
I'd be interested in reading that and am sure others would be too!
On 12/13/14 1:01 PM, Norbert Melzer wrote:
I'd think the details would be of general interest, why don't write an article/blogpost? Am 13.12.2014 18:50 schrieb "Ryan Trinkle"
: I use Nix package manager for binary deployment of Haskell applications, and it works great. Feel free to email me directly if you're interested in the specifics. On Dec 13, 2014 12:34 PM, "Alan Buxton"
wrote: Hi thanks for the input so far.
See attached a zipfile of a simplified version of the app. It runs locally on my dev machine and I want to be able to run it on a separate server. I don’t want to share the app with anyone else.
If I do “cabal install” with this particular application then it creates an executable at ~/.cabal/bin/app1
If I copy that file onto the target server then I get the following output:
$ ./app1 fred
Hi fred
Time now is 2014-12-13 17:27:21.764048 UTC
app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does not exist (No such file or directory)
So sort of works but in particular the file attachment piece doesn’t work.
*From:* Beginners [mailto:beginners-bounces@haskell.org] *On Behalf Of *Kim-Ee Yeoh *Sent:* 13 December 2014 16:53 *To:* The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell *Subject:* Re: [Haskell-beginners] Deploying a haskell application (not a webapp)
On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton
wrote: I now want to deploy this application onto a separate server. This is not a webapp.
Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved).
Looks like there are some assumptions probably based on familiarity with some other language + toolchain.
Of what is the haskell analogue you're looking for?
-- Kim-Ee
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing listBeginners@haskell.orghttp://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Sat, Dec 13, 2014, at 07:24 PM, Alan Buxton wrote:
Hi
I have created an application using cabal that now installs fine and runs fine on my dev machine.
I now want to deploy this application onto a separate server. This is not a webapp.
Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved).
Any advice on the neatest way to do this?
Hi, Can't you build a static binary and deploy it? (something like this -- http://stackoverflow.com/questions/5953199/create-a-static-haskell-linux-exe...) Ramakrishnan http://rkrishnan.org/

Hiya It turned out that my issue was to do with the data files. When compiling locally, cabal puts the files in /home/alan/.cabal/share and the compiled application expects to find the files there. So when I deploy my binary I have to also put some files into /home/alan/.cabal/share which feels wrong. Alternatives to me seemed to be to set up cabal on my dev pc to install globally rather than user-based, but that also feels a bit wrong. Sandboxes looks like they might be useful but I've been having all kinds of problems with getting vmware tools installed on a sufficiently new version of Ubuntu to get a more up to cabal. So I guess the real question behind the question is .. how best to set up your dev environment when developing in Haskell so you don't end up with problems like this one where you have data files compiled into some obscure place. Alan From: Beginners [mailto:beginners-bounces@haskell.org] On Behalf Of Ramakrishnan Muthukrishnan Sent: 16 December 2014 08:13 To: beginners@haskell.org Subject: Re: [Haskell-beginners] Deploying a haskell application (not a webapp) On Sat, Dec 13, 2014, at 07:24 PM, Alan Buxton wrote: Hi I have created an application using cabal that now installs fine and runs fine on my dev machine. I now want to deploy this application onto a separate server. This is not a webapp. Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved). Any advice on the neatest way to do this? Hi, Can't you build a static binary and deploy it? (something like this -- http://stackoverflow.com/questions/5953199/create-a-static-haskell-linux-exe cutable) Ramakrishnan http://rkrishnan.org/

On Tue, Dec 16, 2014 at 8:47 AM, Alan Buxton
I’ve been having all kinds of problems with getting vmware tools installed on a sufficiently new version of Ubuntu to get a more up to cabal.
open-vm-tools{,-desktop} doesn't work? I've been using it in Mint. (In general, the "official" vmware tools don't keep up with open source OSes very well.) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On 12/16/2014 08:47 AM, Alan Buxton wrote:
Hiya
It turned out that my issue was to do with the data files. When compiling locally, cabal puts the files in /home/alan/.cabal/share and the compiled application expects to find the files there. So when I deploy my binary I have to also put some files into /home/alan/.cabal/share which feels wrong.
If you list the data files in Cabal's "data-files" field, and you use Cabal to build on the server, then you can ask Cabal where it put those files at runtime: https://www.haskell.org/cabal/users-guide/developing-packages.html#accessing...

On 12/16/2014 03:24 PM, Michael Orlitzky wrote:
On 12/16/2014 08:47 AM, Alan Buxton wrote:
Hiya
It turned out that my issue was to do with the data files. When compiling locally, cabal puts the files in /home/alan/.cabal/share and the compiled application expects to find the files there. So when I deploy my binary I have to also put some files into /home/alan/.cabal/share which feels wrong.
If you list the data files in Cabal's "data-files" field, and you use Cabal to build on the server, then you can ask Cabal where it put those files at runtime:
https://www.haskell.org/cabal/users-guide/developing-packages.html#accessing...
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
Pretty sure the whole point of this thread is that the OP does not want to build on the server. Personally I have inlined some data files into the source directly at compile time with Template Haskell: no hassle at run-time about finding the files, no hassle with copying them over to the target machine… Of course this might not cut it if your files are huge or are meant to be more dynamic. If that's the case then you should copy the data files along with the binary and teach your program how to find them. -- Mateusz K.

Hi mateusz yes thanks for this. You've basically hit the nail on the head
with that summary "teach your program how to find them".
On 17 Dec 2014 14:17, "Mateusz Kowalczyk"
On 12/16/2014 03:24 PM, Michael Orlitzky wrote:
On 12/16/2014 08:47 AM, Alan Buxton wrote:
Hiya
It turned out that my issue was to do with the data files. When compiling locally, cabal puts the files in /home/alan/.cabal/share and the compiled application expects to find the files there. So when I deploy my binary I have to also put some files into /home/alan/.cabal/share which feels wrong.
If you list the data files in Cabal's "data-files" field, and you use Cabal to build on the server, then you can ask Cabal where it put those files at runtime:
https://www.haskell.org/cabal/users-guide/developing-packages.html#accessing...
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
Pretty sure the whole point of this thread is that the OP does not want to build on the server.
Personally I have inlined some data files into the source directly at compile time with Template Haskell: no hassle at run-time about finding the files, no hassle with copying them over to the target machine… Of course this might not cut it if your files are huge or are meant to be more dynamic. If that's the case then you should copy the data files along with the binary and teach your program how to find them.
-- Mateusz K. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 12/17/2014 09:16 AM, Mateusz Kowalczyk wrote:
Pretty sure the whole point of this thread is that the OP does not want to build on the server.
Oh, sorry, I missed that. You can pass --datadir to Cabal's configure step; e.g. $ runghc Setup.hs configure --datadir=/usr/local/share/<your-app> I believe it's using /home/alan/.cabal/share as the default, but if you tell it to do otherwise, it will.

Oh that's cool. Is there a way to configure this in some file so that when I build just this application a particular datadir is used? -----Original Message----- From: Beginners [mailto:beginners-bounces@haskell.org] On Behalf Of Michael Orlitzky Sent: 17 December 2014 17:53 To: beginners@haskell.org Subject: Re: [Haskell-beginners] Deploying a haskell application (not a webapp) On 12/17/2014 09:16 AM, Mateusz Kowalczyk wrote:
Pretty sure the whole point of this thread is that the OP does not want to build on the server.
Oh, sorry, I missed that. You can pass --datadir to Cabal's configure step; e.g. $ runghc Setup.hs configure --datadir=/usr/local/share/<your-app> I believe it's using /home/alan/.cabal/share as the default, but if you tell it to do otherwise, it will. _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

I add a command line parameter to my programs to specify the location of
config files:
<myProg> -c
Oh that's cool. Is there a way to configure this in some file so that when I build just this application a particular datadir is used?
-----Original Message----- From: Beginners [mailto:beginners-bounces@haskell.org] On Behalf Of Michael Orlitzky Sent: 17 December 2014 17:53 To: beginners@haskell.org Subject: Re: [Haskell-beginners] Deploying a haskell application (not a webapp)
On 12/17/2014 09:16 AM, Mateusz Kowalczyk wrote:
Pretty sure the whole point of this thread is that the OP does not want to build on the server.
Oh, sorry, I missed that. You can pass --datadir to Cabal's configure step; e.g.
$ runghc Setup.hs configure --datadir=/usr/local/share/<your-app>
I believe it's using /home/alan/.cabal/share as the default, but if you tell it to do otherwise, it will.
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 12/18/2014 03:20 AM, Alan Buxton wrote:
Oh that's cool. Is there a way to configure this in some file so that when I build just this application a particular datadir is used?
The usual Setup.hs is just a dummy file; Cabal even ignores it. But if you switch to a "custom" build (from "simple") you can do some preprocessing in Setup.hs: https://www.haskell.org/cabal/users-guide/developing-packages.html In the section "More complex packages", it shows you how to add hooks that get executed before each configure/build/etc stage. If you add a configure hook that mangles the datadir template, you can override the default. Here's a Setup.hs that seems to work: -- Welcome to the jungle, baby. import Distribution.PackageDescription import Distribution.Simple import Distribution.Simple.Configure import Distribution.Simple.InstallDirs import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Setup my_hooks :: UserHooks my_hooks = simpleUserHooks { confHook = my_conf_hook } main :: IO () main = defaultMainWithHooks my_hooks my_conf_hook :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo my_conf_hook (gpd,hbi) cf = do lbi <- configure (gpd, hbi) cf let orig_dirs = installDirTemplates lbi let my_datadir = toPathTemplate "/foo/bar" let my_dirs = orig_dirs { datadir = my_datadir } let my_lbi = lbi { installDirTemplates = my_dirs } return my_lbi

Does anyone have any experience with Halcyon[1]? It purports to do just
this.
[1] https://halcyon.sh/
--
vale cofer-shabica
<401.267.8253>
On Thu, Dec 18, 2014 at 10:39 AM, Michael Orlitzky
On 12/18/2014 03:20 AM, Alan Buxton wrote:
Oh that's cool. Is there a way to configure this in some file so that when I build just this application a particular datadir is used?
The usual Setup.hs is just a dummy file; Cabal even ignores it. But if you switch to a "custom" build (from "simple") you can do some preprocessing in Setup.hs:
https://www.haskell.org/cabal/users-guide/developing-packages.html
In the section "More complex packages", it shows you how to add hooks that get executed before each configure/build/etc stage. If you add a configure hook that mangles the datadir template, you can override the default. Here's a Setup.hs that seems to work:
-- Welcome to the jungle, baby. import Distribution.PackageDescription import Distribution.Simple import Distribution.Simple.Configure import Distribution.Simple.InstallDirs import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Setup
my_hooks :: UserHooks my_hooks = simpleUserHooks { confHook = my_conf_hook }
main :: IO () main = defaultMainWithHooks my_hooks
my_conf_hook :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo my_conf_hook (gpd,hbi) cf = do lbi <- configure (gpd, hbi) cf
let orig_dirs = installDirTemplates lbi let my_datadir = toPathTemplate "/foo/bar" let my_dirs = orig_dirs { datadir = my_datadir } let my_lbi = lbi { installDirTemplates = my_dirs } return my_lbi
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (12)
-
Alan Buxton
-
Brandon Allbery
-
Christopher Reichert
-
Corentin Dupont
-
Kim-Ee Yeoh
-
Mateusz Kowalczyk
-
Michael Orlitzky
-
Norbert Melzer
-
Ramakrishnan Muthukrishnan
-
Ryan Trinkle
-
Thomas Jakway
-
Vale Cofer-Shabica