How to deploy a web app without stop and restart - go

I built the project to binary file and deployed it to server before. and start it with nohup. But if I updated my code and rebuild my program. I must to kill the process first, then updated the file and start again.
My problem is:
The app must be down with at least few seconds.
I must update file manually (login the server, kill process, replace file, and then start it)
Is there anyway to hot update the program, something like PHP? I just need update my code to server by git (or svn or others way). then the server will rebuild app and graceful restart it.

Usually you run more than one instance of your web application behind a reversed proxy, eg nginx, or any other load balancer. If the few second downtime is an issue for you then you need to have a HA setup anyway. And in such setup you can do a rolling update, where you are replacing instances one by one.
Quick googling will let you find instructions how to do the deployment eg: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-go-web-application-using-nginx-on-ubuntu-18-04

Related

Re-deploy of a Tomcat application causes the active sessions to be dropped

I have a tomcat application which I deploy by placing the new my-project.war file into the /var/lib/tomcat8/webapps/ directory on my server (via scp).
Every time I do this, the new copy is live a few seconds later. The only problem is that it drops all the sessions.
All the documentation I can find tells me that Tomcat should restore the sessions by default. This does seem to be the case when I restart the Tomcat service, but not when I redeploy...
Can anyone tell me whats going on here? I don't fully understand why it works to deploy this way in the first place.
The default session manager - StandardManager saves the sessions in <tomcat-home>/work/<app-name>/SESSIONS.ser. When you stop tomcat, the sessions are serialized into that file. When you start it - they are loaded from it.
But when you re-deploy your applications two things happen:
Tomcat un-deploys the old app and deletes the <tomcat-home>/work/<app-name>/ folder, thus removes the saved sessions
Tomcat deploys the new app and creates a new folder
Or in two words - tomcat deletes the saved sessions on un-deploy. I guess this is because:
the re-deploy is implemented as undeploy -> deploy. I.e. the 'undeploy' step does not know if a new version of the app will be deployed, so it makes sure to properly clean up after itself.
it's better from security perspective

Undeploying Business Network

Using HyperLedger Composer 0.19.1, I can't find a way to undeploy my business network. I don't necessarily want to upgrade to a newer version each time, but rather replacing the one deployed with a fix in the JS code for instance. Any replacement for the undeploy command that existed before?
There is no replacement for the old undeploy command, and in fact it it not really undeploy - merely hiding the old network.
Be aware that everytime you upgrade a network it creates a new Docker Image and Container so you may want to tidy these up periodically. (You could also try to delete the BNA from the Peer servers but these are very small in comparison to the docker images.)
It might not help your situation, but if you are rapidly developing and iterating you could try this in the online Playground or local Playground with the Web profile - this is fast and does not create any new images/containers.

Laravel Restore a Backup

I'm fairly new to server administration. I have my Laravel app up and running and I want to make sure it has proper backups. I have researched some backup packages and I have settled on https://github.com/spatie/laravel-backup.
However, once the server fails, I need to know how to use the most recent backup (which will be on AWS S3) to restore the database on the rebuilt server. Are there any suggestions for guides on how to do this? I can't seem to find any unless it doesn't really require much learning and instead just a couple mySQL commands.
Thanks!
I would use replication and within Laravel i would try to switch connection to the replica database server so things can run smoothly until the problem is resolved.
Take a look at this Cross-Region Replication
A typical production environment is automatically running backups on most important things that your deployment needs in order to recover from a failure. Those parts would commonly be your database and storage folder, and configuration files.
Also when you deploy a laravel application there aren't many things that are "worth" backing up , you can choose the entire disk to be mirrored somewhere or you can schedule a backup script which run every N times and backups the things that are more important to your application.
Personally i wouldn't rely on an package from laravel to handle my backups , you can always use other backup utilities, replication and so on.
Update
Take a look at the link below:
User Guide » Amazon RDS DB Instance Lifecycle » Backing Up and Restoring
Backing Up and Restoring
You can call the API function RestoreDBInstanceFromDBSnapshot as showed on example.
But i don't think something automated exists that would auto restore or magically make everything work, you need to do a lot of security checks if something like that would even be attempted. Final word i believe a good solution manually entering or sending the request would be the most solid solution.

How to get rid of this error when starting Tomcat

I am adding some things in an existing Android app, which connects to a Apache Tomcat server to get information from a database, but some of the changes required that I also make minor changes on the webapp (changing some database fields).
I had never used tomcat, but managed to do the simple changes here and there.
But when I deployed it, I noticed some errors(see the photo).
How can I fix them ?
The app works regardless of them, but the server takes a few more seconds to start up.
P.S.I read somewhere that this means that the server already has these libs, and doesnt need to use the ones from the lib folder of the app ?

VS2013 Web Deploy Replace from Server error

I have deployed web applications using web deploy on to iis7.5 without issues, the preview works and It updates only the necessary files when publishing again. We have designers who like to change the css files with FTP and I thought the Replace fileName from server commands in Visual Studio would be great to pull their changes into TFS.
Every time I run it it comes up with the error :
The synchronization is being stopped because the maximum number of sync passes '5' has been exceeded even though all the changes could not be applied. This could occur if there are external changes being made to the destination.
If anyone could shine some light on the error or some documentation regarding this feature, that would be great.
Web Deploy does at least 2 passes to do a remote sync (when either the client or server is remote which is in your case too). At the end of these passes, web deploy does a metadata check to see if all the files are in sync.
If by then other changes have happened (such as someone else started a web deploy sync to the same destination, or a few files were edited via the web or via ftp or any other means) then web deploy will attempt a 3rd pass to get them in sync with the source. If the changes keep happening the passes will keep happening.
But since we dont want to sync the content for ever we placed a max retry limit of 5. You can actually override to something higher but its not recommended.
Update:
You can set this in two ways:
pass in a flag -retryAttempts=7 (or any number) to msdeploy from command line
Set RetryAttemptsForDeployment in VS targets or use it as an MSBuild property. Its described here

Resources