Add Launch Script after Lightsail Creation?

0

My lightsail instance needs a launch script, but I can only find documentation on setting those up when first creating the server.

Where does the launch script live on the server? I'd love to just ssh in, edit it, and be done.

baudot
質問済み 3年前1256ビュー
5回答
0
承認された回答

I did a bit of poking around ... looks like you can just put your startup script in /etc/rc.local and it will run.

Make sure you make /etc/rc.local executable (chmod a+x /etc/rc.local).

profile picture
David G
回答済み 3年前
0

What blueprint are you using?

There are various ways to accomplish a launch script, but it depends on the blueprint.

profile picture
David G
回答済み 3年前
0

I'm using MEAN.

baudot
回答済み 3年前
0

Baudot,

Thanks for using Lightsail!

Here is a doc about launch scripts: https://lightsail.aws.amazon.com/ls/docs/en_us/articles/lightsail-how-to-configure-server-additional-data-shell-script

The doc does not explicitly state this but it is important to note that the launch script is only executed on initial launch of the instance, not on every launch. For that reason there is no way to configure the launch script after the instance is initially created.

If you require software to run on every launch of the instance, you should use the os-dependent initialization software such as 'initd' on linux and startup programs on Windows.

I hope this helps!

Donley

profile pictureAWS
回答済み 3年前
0

David - thanks, that worked.

I had to do few more debugging steps to get my script running properly.

In the end the script ended up looking like:

#!/bin/sh

(
cd /full/directory/path/to/my/app
/full/path/to/init_command 1>/var/log/my_app_name/my_app_name.log 2>&1 &
)

...and that did it.
If anyone else runs into a similar hurdle, hopefully this helps.

baudot
回答済み 3年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ