Running a program on a server lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- vicot · 2016-01-25 17:20 I am trying to collect information about setting up and running a FreePascal program on a server. The problem is that I don't know the first thing about servers. I have noticed that there are already FreePascal web servers and frameworks for writing server-side applications, but I am not sure if this is what I actually need. Probably not, I guess, since I do not need to serve web pages or use databases. What I need is simply running my own program on a server. It should be able to communicate with other similar programs on other servers. So the functionalities required are very few (email protocols and SFTP). About these functionalities, I have already found all the necessary information. (In case anyone wonders, I am an amateur programmer who dreams about playing with distributed computing, for fun...) Could someone please point me in the right direction? What servers will allow me to run my (compiled, of course) Pascal program? Especially, what are the practical steps that I should take in order to get a server to run a program all the time (not limited to the time when I access my account)? I know that these are basic questions, and I do not expect you to explain everything in detail to a newbie. Some links or some key words that I can Google would be fine, so I can find out the basic info by myself. Thanks a lot. --vicot ---------------------------------------------------------------------- eny · 2016-01-25 21:56 If you develop for a server and the program needs to be up and running all the time, you need to develop it as a Service or Daemon (Linux/Windows). http://wiki.freepascal.org/Daemons_and_Services ---------------------------------------------------------------------- Leledumbo · 2016-01-26 07:58 A server is just another computer. Most of the time it's headless so you don't have GUI access, but that's it. Everything else should be pretty much the same as normal computer (well, minus the hardware spec). Quote from: vicot on January 25, 2016, 06:20:40 pmEspecially, what are the practical steps that I should take in order to get a server to run a program all the time (not limited to the time when I access my account)? Direct daemon or hosted by another daemon (e.g. supervisor). Nohup can be the simplest solution. ---------------------------------------------------------------------- vicot · 2016-01-27 19:11 Thanks guys for your answers. I really appreciate your help. I have a few more related questions: 1) do servers have restrictions about running closed-source daemons? My fear (but then I am just a newbie) is that they might worry about the program accessing their own server-based private stuff (which my program would not do, of course) 2) do server administrators monitor what the running daemons do? This is a privacy-related question. In general, should I trust that the server administrators do not snoop inside my running programs? Or should I assume that they do? 3) What servers would you recommend to a newbie who intends to run daemons (written in Pascal)? Any free option available? (my requirements are very limited BTW) Thanks again for your help --vicot ---------------------------------------------------------------------- Phil · 2016-01-27 19:22 vicot, I doubt if you'll find any "free" servers that permit executable code to run like what you propose. You might be able to find a server that permits some limited PHP scripts, but certainly not a Pascal binary. Good news, though, is that at least one exception would be the Amazon Web Services "Free Tier". See Part 4 of my Pascal Dynamic Libraries series for notes on how to set up both a Linux and Windows server on AWS. https://dl.dropboxusercontent.com/u/28343282/ObjP/index.html You'll be the admin and you can access and install pretty much anything on your own virtual server that you want. I access my Windows instance on AWS via Microsoft's Remote Desktop software on my Mac (free from Apple Mac store). That way I can even install interactive apps - like having a Windows computer in a window on my Mac. -Phil ---------------------------------------------------------------------- Leledumbo · 2016-01-28 10:09 Quote from: vicot on January 27, 2016, 08:11:15 pm1) do servers have restrictions about running closed-source daemons? My fear (but then I am just a newbie) is that they might worry about the program accessing their own server-based private stuff (which my program would not do, of course) Are you confused between server and hosting? The former is a OS with your complete control, the provider only controls the hardware and network. The latter is a small part of the OS and filesystem whose access is given to you. Quote from: vicot on January 27, 2016, 08:11:15 pm2) do server administrators monitor what the running daemons do? This is a privacy- related question. In general, should I trust that the server administrators do not snoop inside my running programs? Or should I assume that they do? You are the server administrator. They may enter your machine instance if you give them one of the available accounts in the OS you manage. Otherwise, they only have access to the server instance, not the OS inside it. Quote from: vicot on January 27, 2016, 08:11:15 pm3) What servers would you recommend to a newbie who intends to run daemons (written in Pascal)? Any free option available? (my requirements are very limited BTW) koding.com offers free access, but will me frozen when when no activity for certain period detected. It's good enough for learning server administration. Other options are Amazon AWS, IBM Softlayer, Microsoft Azure, Google Compute Engine, Digital Ocean, etc. I'm not sure if any of them provide free services. ---------------------------------------------------------------------- bee · 2016-01-28 13:04 It's 2016. There are many free hosting and VPS out there now. At least very cheap that cost you just a few bucks a month. You just need to google it. My recommendation is koding.com. It's a free full featured 64 bit Linux Ubuntu 14.04 machine on the cloud for custom development purposes. It comes almost without any technical limitations, except for some common inappropriate usages like spam bot and the like. You even have the root access with it. So, you can install Free Pascal on it and freely experiment with server side app development. It also has a facebook-like community with friendly and helpful people. I've been using koding for quite a while and I'm happy with it. So far so good. I've done many Pascal experiments on it. Check out my custom code repository here: http://beeography.koding.io/viewcode.cgi PS. I'm not whatsoever related with Koding. I'm just a happy customer. ---------------------------------------------------------------------- bee · 2016-01-28 13:42 Oh, by the way… a server is just a computer that could reply to remote requests over some network protocols (tcp, udp, etc), and usually it comes with some server apps that serve some communication protocols (http, smtp, etc). Nothing less, nothing more. For a simple web app, you don't need fancy frameworks. You just need a web server (to serve http protocol) and a way to read from standard input and to write to standard output. The standard Pascal readln/writeln procedures are enough. You can also write your own web server (FPC has the unit for it), if you really need to. But, using common ready to use web server, like Apache, Nginx, etc, is much easier and simpler. This is the most simple web app using Pascal: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program hello;begin  writeln('content-type: text/html;');  writeln;  writeln('Hello World from Pascal!');end. Of course you would need more than just 'Hello World from Pascal!' string to build a complete and correct HTML document. I made a little experiment to ease simple web app creation, called webcrt unit. With this unit, you could write a simple web app almost like a console app. Take a look at a webcrt example here: http://beeography.koding.io/hello.cgi (source code included). However, once you need more than just a simple web app, you need more than just to read/write from/to standard i/o. You need tools to manage your app. That's when frameworks or libraries come to help. FPC has fpWeb package especially for web app development. But there are some other third party frameworks as well, like Brook, ExtPascal, etc. Server app development is fun. With koding and FPC, you have all the tools you need to start your journey. Have fun!