I'd like to create a simple web application to manage some data. The application will use PostgreSQL but I have no idea how to package everything in order to make it run on windows, linux, and mac. I can cross-compile a go binary which will include everything (web server, etc..) but the postgresql database will be left out because that's running as a separate server locally. I heard about docker but I don't know if that's the right solution.
Should I create a docker container and include PostgreSQL in it so I can start that web app on any platform?
You don't need Docker to do this.
It complicates things since your users will have to install the Docker engine first. Go is perfectly capable for cross platform applications, batteries included.
Decide if you want your app to run in a browser tab or should it have it's own window?
For a browser tab compile your app for the target architecture and think about a URL scheme that will make sense to your users, for example
localhost:8080/app => the user interface. This route is the web app, it serves HTML, JS and CSS. Tell your users to run the executable (or install it as a service, see this or use a platform specific tool like this one). Then open the link in a browser
localhost:8080/api => backend routes. Serves data to requests made by the user interface. For talking to the Postgres server running locally
If you want your app to run in it's own window have a look at Electron. See gotron: Go Api for Electron
If you want to use Docker for this, you have to create a platform-specific docker image containing the platform-specific binary in it. Once you have these images, you can use docker-compose to run your app with an instance of postgres running in its own container.
Related
I am developing a Meteor application on Windows. Are there log files being stored somewhere? Where are they?
To be more specific, I am running the development server on my local pc. I need to see any logs being created by the server. I need to know where they are stored.
I don't think they are stored in files. You need to handle logging in your code and also look for meteor process STDOUT/STDERR.
Perhaps you can take a look at this project for a solution/inspiration:
https://github.com/VeliovGroup/Meteor-logger
For production environment, I can accept that golang can not hot swap. But for development mode, must I recompile whole project, and restart server, even just modify 1 line of code? Is there any way to quickly hot swap code to check result for debugging?
You use or create a watcher process that looks for changes, will recompile and restart the server when it identifies a change.
Here are some examples of this. I use Beego and bee rebuilds my server during development all the time.
Gin
GitHub: https://github.com/codegangsta/gin
gin is a simple command line utility for live-reloading Go web applications. Just run gin in your app directory and your web app will be served with gin as a proxy. gin will automatically recompile your code when it detects a change. Your app will be restarted the next time it receives an HTTP request.
Fresh
GitHub: https://github.com/pilu/fresh
Fresh will watch for file events, and every time you create/modify/delete a file it will build and restart the application. If go build returns an error, it will log it in the tmp folder.
Fresh works specifically with Traffic, Martini and gocraft/web.
Beego bee
The Beego web framework also does this. This is implemented in bee, a CLI tool for running Beego.
Website: https://beego.me/
Framework: https://github.com/astaxie/beego/
CLI App: https://github.com/beego/bee
bee will watch all the project directories by default and has an option to also watch the vendor directory.
I'm following the tutorial to deploy a ruby app to google compute engine. Everything works, however I now want to ssh into the app to run migrations etc. After some searching i was able to find my files under a docker instance here /var/lib/docker/aufs/diff/e2972171505a931749490e13d21e4f8c0bb076245ef4b592aff6667c45b2dd13/app
Is there a simpler way to access my files? perhaps a symlinked folder?
Ruby apps on Google AppEngine run via Docker. Because AppEngine is a PaaS provider, it's discouraged (though possible) to run commands on production machines. If you'd like to run database migrations, please run them locally and point your configuration at your production database.
I generated the default RoR application with the rails new <project_name> command, and everything seemed to go fine. Later I decided I wanted to relocate my rails projects in a different directory (something other than my home directory), so I moved the RoR project to /opt/rails/<project_name> and I created a symlink in my web root pointing to /opt/rails/<project_name>/public, and the page loads fine, but some of the assets aren't loading on the Welcome aboard page, i.e. the rails.png And when I go to click on the About your application's environment link I get a 404 error. If I had to take a guess as to why I'm getting these errors it would have to be that I moved the rails app simple_cms from /home/user/www/rails/simple_cms to /opt/rails/simple_cms Is there a command I need to issue in the project root of simple_cms to get things fully working?
Update
I'm using Apache 2 as the web server on a CentOS 5.9 box.
If you are using rails s to launch your app, then there is no need to create symlinks. The web server (could be WEBrick, or Thin) will serve the application from the app root.
If you are using Apache or Nginx, again there is no need to create symlinks, but you need to let Apache/Nginx know the new location. For example, in a Nginx+Passenger setup, you would need to set passenger_app_root to the new location.
Provide more details in your question, or consult the documentation for your setup.
I want to build application which servers as a stand-alone system service, always run on the backend and servers a front-end with a web interface.
Like we do in Linux /etc/init.d/apache2 start , Same as I want to server my application /etc/init.d/myapp start.
My major target is to deliver on Linux specially Ubuntu, whole app would be in plain Ruby and front-end would be in Sinatra.
I want to make it install with simple, gem install my_app and command line features get available to start the service. The application would be doing heavily processing and database insertion. And I want that its configurations must be set as in pure linux fashion, like /etc/apache2/apache2.conf
Can any one guide me in it? Also if possible, i want to secure the code, is there any possibilities for it?
I am using the Daemon-Kit gem for the same requirements. Works very well in production. The only thing it does not include is the configuration with a .conf file, but it's easy to do it yourself with Ruby code. You can deploy with Capistrano, no need to install.