Does a Lightsail launch script only run at new instance initialisation? - ubuntu-18.04

When creating a new Ubuntu Lightsail instance and adding a launch script is the script you enter only run when you FIRST initialize the instance and NOT every time you reboot or restart the same instance? I would love to automate updates and install applications when I create the instance, but I would also like to run updates and start servers when the instance is rebooted or restarted.
Can I (should I) use the launch script for this? Or would it be better to create a second script to do all the tasks after reboot?

Related

Add seed data to a Docker based Microsoft SQL Server at image build time

NOTE: I believe that this question is different than the many others that look similar. Please read it before closing.
I am trying to build a Docker container image that has a "for testing" copy of my database. I have a script that will create this. It takes about 60 seconds to run.
I put this into a docker container by following the steps outline by Julie Lerman here. It worked just fine except that it runs my script when the container instance is created. This means that I have to wait 60 seconds before the database is fully ready.
I want to incur the 60 second cost when the image is built, not when the container starts up (startup is when my automated tests need it to be ready fast!)
How can I create a Sql Server container image that has my database script pre-run?
NOTE: I need this to be a repeatable, auto-build process. As such I am hesitant to use docker commit
This command ended up doing it:
RUN ( /opt/mssql/bin/sqlservr --accept-eula & ) | grep -q "Service Broker manager has started" && /createScript.sh
createScript.sh is a bash script that calls SqlCmd on the sql script you want to run.
The key is to do a RUN, so it is done at image build time.
Source: https://github.com/microsoft/mssql-docker/issues/229

wildfly-maven-plugin:1.2.1.Final start and run do not work for remote host

I have used wildfly-maven-plugin:1.2.1.Final and deploy,undeploy & shutdown all work for locally and also remotely.
The problem I is that the start and run goals do not work for a remote host. It seems like it does not use the same config for goals like deploy, undeploy & shutdown
Any ideas how I configure so that run or start work for remote host?
Thanks,
daslan
The wildfly-maven-plugin cannot start a remote WildFly instance. With both the start and run goals the plugin starts a new process locally. There is no way, at least that I'm aware of, to start a new process on a remote machine.
The deploy, redeploy, undeploy and shutdown goals work because they send requests over the management API.

Exe running as a Service instead of a Application

Situation
I have a Win 2012 server in which i run an exe which is essentially a GUI. The server restarts every monday so on monday morning i have to log-on to the server using a generic account and manually start the exe.
Setup
I am planning to automate the activity of starting the exe every monday. For that i have written a batch file which starts the exe with some parameters. Also i have created a scheduled task that runs on Monday and triggers the batch file. The trigger that i have used in the scheduled task is "At Startup".
ISSUE
The issue that i am facing is that after the server is restarted i am not seeing my GUI(exe) running. When i checked on the Task Manager it is showing it running as Background Process however it is not coming to front and i am not seeing the GUI. I might be wrong but i think the exe is running as a process/service instead of running as an App.
Can someone please suggest a solution for this issue.
Thanks in advance.

Cannot connect to X11 from service

I have written a daemon that connects to the X server and queries information periodically. I have configured the daemon to run on startup as a service, using chkconfig. It is set for run level 5. The start command for the init script runs the command my_daemon &.
When the daemon is running, however, it cannot connect to the X server display, even after several minutes. The command I use to connect is:
display = XOpenDisplay(NULL)
The script works fine when I just run my_daemon & manually from a terminal. So, how can I get it working as a startup service?

Running batch file remotely using Hudson

What is the simplest way to schedule a batch file to run on a remote machine using Hudson (latest and greatest version)? I was exploring the master slave setup. I created a dumb slave but I am not sure what the parameters should be so that I can trigger the batch file in the remote slave machine.
Basically, I am trying to run 2 different batch files on two different remote machines sequentially, triggered from my machine (the master). The Step by step guide on the Hudson website is a dead link. There are similar questions posted on SO but it does not quite work for me when I use the parameters they mention.
If anyone has done something similar please suggest ways to make this work.
(I know how to set up jobs, and add a step to run a batch file etc what I am having trouble configuring is doing this on a remote machine using hudson in built features)
UPDATE
Thank you all for the suggestions. Quick update on this:
What I wanted to get done is partially working, below are the steps followed to get to it -
Created new Node from Manage Nodes -> New Node -> set # of Executors as 1, Remote FS root set as '/var/hudson', set Launch method as using JNLP, set slavename and saved.
Once slave was set up (from master machine), I logged into the Slave physical machine, I downloaded the _slave.jar from http://masterserver:port/jnlpJars/slave.jar, and ran the following from command line at the download location -> java -jar _slave.jar -jnlpUrl http://masterserver:port/computer/slavename/slave-agent.jnlp. The connection was made successfully.
Checked 'Restrict where this project can be run' in the Master job configuration, and set paramater as slavename.
Checked "Add Build Step" for adding my batch job script
What I am still missing now is a way to connect to 2 slaves from one job in sequence, is that possible?
It is fairly easy and straight forward. Lets assume you already have a slave running. Then you configure the job as if you are locally on the target box. The setting for Restrict where this project can be run needs to be the node that you want to on. This is all for the job configuration.
For the slave configuration read the following pages.
Installing Hudson as a Windows service
Distributed builds
On windows I prefer to run the slave as a service and let the remote machine manage the start up and shut down of the slave. The only disadvantage with this is, you need to upgrade the client every time you update the server Just get the new client.jar from the server, after the upgrade and put it on the slave. Then restart the slave and you are done.
I had troubles using the install as a service option for the slave even though I did it as a local administrator. I used then srvany to wrap the jar into a service. Here is a blog about it. The command that you need to wrap, you will get from your Hudson server from the slave page. For all of this to work, you should set up the slave management as jnlp.
If you have an ssh server on your target machine, you can use the ssl slave settings. These work for me like a charm. I use them with my unix slaves. So far the ssl option with unix is less of an hassle, than the windows service clients.
I had some similar trouble with slave setup and wrote up this blog post - I was running on Linux rather than Windows, but hopefully this will help.
I dont know about how to use built-in hudson features for this job - but in one of my project builds, i run a batch file that in turn uses PSTools
to run the job on a remote server. I found PS tools extremely easy to use - download, unpack and run the command with the right parameters, hence opted to use this.

Resources